More thoroughly reject direct access to unintended files, such that
URIs like http://man.openbsd.org/OpenBSD-current/mandoc.db and
http://man.openbsd.org/OpenBSD-current/man1/ do not cause display
of garbage.
Now that global -i is gone, pass -i through to the apropos(1)
expression parser, such that "apropos -i 'Nm~dump\>'"
finds kdump(1) and WCOREDUMP(2) and you don't need
to type the counter-intuitive "apropos -- -i 'Nm~dump\>'".
Delete the undocumented and unimplemented man(1) -i (interactive
apropos) option. It will not be implemented. Featurism isn't the
plan for the future; simplicity is.
The apropos(1) manual still documents the unary -i operator for
regular expression search terms, but it appears that somewhere
along the way, the implementation got lost, so restore it.
Bug found while investigating other reports from Gonzalo Tornaria.
Restore -kO Nd, -kO Nm, -kO sec, and -kO arch to working order.
They got broken in the SQLite removal.
As opposed to the rest of -kO, they are no longer very useful,
but they are certainly not supposed to fail assertions.
Issue reported by Gonzalo Tornaria <tornaria at cmat dot edu dot uy>.
Fix handling of trailing punctuation in .Lk.
This macro is unusual in so far as trailing punction needs to remain
inside the scope because it must be inside, not after the display
of long URIs in terminal output mode.
Improves formatting of fw_update(1), help(1), less(1), sendbug(1),
acx(4), inet6(4), ipsec(4), oce(4), isakmpd.conf(5), afterboot(8),
release(8), traceroute(8).
Ingo Schwarze [Sat, 25 Mar 2017 12:46:36 +0000 (12:46 +0000)]
For some options that are rarely needed in apropos(1) and man(1),
delete the verbose descriptions and point to man(1) and mandoc(1),
respectively, instead. That shortens the pages and makes them
easier to read.
Tweaks and OK jmc@, based in part on ideas from tedu@.
Ingo Schwarze [Mon, 20 Mar 2017 14:32:24 +0000 (14:32 +0000)]
Silently ignore invalid -m input formats rather than erroring out.
As observed by Jan Stary <hans at stare dot cz>, this is useful such
that after 'alias man="man -m $HOME/man"', 'man -l foo.1' still works.
Simplify and shorten the description of -m, and use .Ic for macros.
Ingo Schwarze [Fri, 17 Mar 2017 12:10:16 +0000 (12:10 +0000)]
Fix regression in mdoc_html.c 1.275, man_html 1.134:
For .Sh, .Ss, .SH, .SS, only write selflink if an id could be constructed.
Crash reported by Raf Czlonka <rczlonka at gmail dot com>,
analysis of root cause by natano@
Ingo Schwarze [Wed, 15 Mar 2017 13:18:53 +0000 (13:18 +0000)]
Mention the manual page name and section in the HTML page <title>.
Based on a patch from <Anton dot Lindqvist at gmail dot com>,
but simplified and also covering apropos(1) search results.
Ingo Schwarze [Wed, 15 Mar 2017 11:29:53 +0000 (11:29 +0000)]
Minimal support for deep linking into man(7) pages.
As the man(7) language does not provide semantic markup,
only .SH, .SS, and .UR become anchors for now.
Ingo Schwarze [Wed, 15 Mar 2017 10:17:29 +0000 (10:17 +0000)]
It's annoying that people keep writing URIs including redundant parts
like "/OpenBSD-current/manN/". To discourage that, let man.cgi(8)
redirect search form results to nice, concise URIs.
Ingo Schwarze [Tue, 14 Mar 2017 01:35:15 +0000 (01:35 +0000)]
Slightly increase widths calculated from string lengths (mainly
for .Bl -tag lists and SYNOPSIS .Nm blocks), such that the text
still fits even if it is printed in bold font.
This is an ugly band aid - but implementing font-dependent width
measurements would be a major project and even more difficult
for HTML than for PostScript.
Issue reported by Jan Stary <hans at stare dot cz>.
Ingo Schwarze [Mon, 13 Mar 2017 20:22:18 +0000 (20:22 +0000)]
Port ctags-style, less(1) :t internal searching from terminal output
to HTML output. For certain macros appearing at the beginning of .It
heads, write HTML id="..." attributes such that deep linking works.
Write HTML <a> attributes such that you can easily copy out link
targets with the mouse. Try: http://man.openbsd.org/vmctl.8#create
Feature suggested by <guettliml at Thomas dash Guettler dot de>,
some details of the design and implementation by me.
Ingo Schwarze [Mon, 13 Mar 2017 19:01:38 +0000 (19:01 +0000)]
Print title="..." in addition to id="..." attributes for macro keys
that can be searched for by apropos(1), such that you see the
semantic function in a tooltip when hovering with the mouse.
Ingo Schwarze [Sat, 11 Mar 2017 15:43:04 +0000 (15:43 +0000)]
Improve detection of recursive eqn(7) "define" statements:
Do not only catch "define key 'key other stuff'",
but also "define key 'other stuff key'".
Fixing infinite loop found by tb@ with afl(1).
Ingo Schwarze [Sat, 11 Mar 2017 12:35:45 +0000 (12:35 +0000)]
In markdown, autolinks are dangerous. Different compilers disagree
with respect to what constitutes a valid autolink, and if a compiler
deems an autolink invalid, the input turns into an unintended and
potentially harmful raw HTML tag. So, never write autolinks.
Instead of <link>, write [link](link).
Instead of <addr>, write [addr](mailto:addr).
Issue pointed out by bentley@, who also agrees with the general
direction of the change.
Ingo Schwarze [Thu, 9 Mar 2017 15:33:40 +0000 (15:33 +0000)]
Really commit some files that failed to get committed in this commit:
Now that markdown output is tested for almost everything, test all
input files in -T markdown output mode by default and only mark
those files with SKIP_MARKDOWN that are not to be tested.
Much easier to read, and almost minus 40 lines of Makefile code.
Ingo Schwarze [Thu, 9 Mar 2017 15:29:35 +0000 (15:29 +0000)]
Fix blunder in previous: we must keep the line parse buffer
consistent even when aborting the parsing of the line. That buffer
is not our own, but owned and reused by mparse_buf_r(), read.c.
Returning without cleanup leaked memory and caused write overruns
of the old, typically much smaller buffer in mparse_buf_r().
Promptly noticed by tb@ with afl(1), using MALLOC_OPTIONS=C.
Ingo Schwarze [Wed, 8 Mar 2017 22:54:22 +0000 (22:54 +0000)]
Now that markdown output is tested for almost everything, test all
input files in -T markdown output mode by default and only mark
those files with SKIP_MARKDOWN that are not to be tested.
Much easier to read, and almost minus 40 lines of Makefile code.
Ingo Schwarze [Wed, 8 Mar 2017 19:40:59 +0000 (19:40 +0000)]
Document that -T markdown produces ASCII output, and the implied
limitations. Of course, we could write UTF-8 output instead,
but even the CommonMark specification doesn't require parsers
to support that, so portability would be doubtful.
While here, provide a link to the CommonMark specification.
Ingo Schwarze [Wed, 8 Mar 2017 17:51:58 +0000 (17:51 +0000)]
The CommonMark specification allows list markers fo the form "number) "
as well as "number. ", so escape closing parentheses after leading digits
to improve portability.
Ingo Schwarze [Wed, 8 Mar 2017 17:40:55 +0000 (17:40 +0000)]
Do not increment .Bl -enum list markers beyond two digits.
Otherwise, we would indent subsequent paragraphs less than
the CommonMark specification requires, harming portability.
Ingo Schwarze [Tue, 7 Mar 2017 20:00:08 +0000 (20:00 +0000)]
If a user-defined macro is aborted because it exceeds the stack
limit, usually due to infinite recursion, discard whatever remains
in all those open stack levels. Otherwise, insane constructions
like the following could generate macros of enormous size, causing
mandoc(1) to die from memory exhaustion:
.de m \" original macro definition
.m \" recursion to blow up the stack
.de m \" definition to be run during the call of .m marked (*)
very long plain text (some kilobytes)
.m \" expand the above a thousand times while unwinding the stack
.. \" end of the original definition
.m \" (*) recursively generate a ridiculously large macro
.. \" end of recursively generated definition
.m \" execute the giant macro, exhausting memory
Ingo Schwarze [Mon, 6 Mar 2017 17:26:04 +0000 (17:26 +0000)]
Using .Nd only makes sense in the NAME section.
Warn if that macro occurs elsewhere.
Triggered by a question from Dag-Erling Smoergrav <des @ FreeBSD>.
Ingo Schwarze [Sun, 5 Mar 2017 19:57:39 +0000 (19:57 +0000)]
Infrastructure for -T markdown tests.
This is needed because -T marksdown is expected to receive less
maintenance than -T ascii, so we need automation to make sure
that regular parser maintenance doesn't break this output mode.
Ingo Schwarze [Sat, 4 Mar 2017 16:36:29 +0000 (16:36 +0000)]
Debian needs relative symlinks not only for manual pages,
but also for program files.
Issue reported by Michael <Stapelberg at debian dot org>
and by Markus <Waldeck at gmx dot de>.
Ingo Schwarze [Fri, 3 Mar 2017 15:05:48 +0000 (15:05 +0000)]
Markdown output mode helped us to find the first parser bug (as such,
this bug could cause wrong output in other modes as well):
Do not misinterpret tab characters as .Ta macros when they appear
on non-column .It lines in non-column .Bl lists that are nested
inside a parent .Bl -column list. (Admittedly, such constructions
are not very useful; don't use them!)
Found by tb@ with afl(1) because the resulting tree corruption
triggered an assertion in the markdown output module.
Ingo Schwarze [Fri, 3 Mar 2017 13:41:42 +0000 (13:41 +0000)]
Fix a copy-and-paste error that caused man(7) manuals without
a section number in .TH to be misinterpreted as preformatted.
Found by jsg@ with cppcheck.
Ingo Schwarze [Fri, 3 Mar 2017 13:11:21 +0000 (13:11 +0000)]
A missing initialization could randomly cause regular expression
searches to be case-insensitive that ought to be case sensitive.
Found by jsg@ with scan-build.
Ingo Schwarze [Wed, 22 Feb 2017 08:54:41 +0000 (08:54 +0000)]
Handle an odd edge case where .It is preceded by .Sm.
NULL dereference in man.cgi reported by Gabriel Guzman <gabe at
guzman dash nunez dot com> on misc@.
Ingo Schwarze [Fri, 17 Feb 2017 19:15:41 +0000 (19:15 +0000)]
Use typographic quotes rather than '"' for .Rs %T (no change for -Tascii
output, of course). Patch from bentley@ in November 2014. This can be
committed now because groff merged Anthony's patch yesterday.
Ingo Schwarze [Fri, 17 Feb 2017 18:28:06 +0000 (18:28 +0000)]
Many people have been complaining for a long time that ``...'' looks
ugly in -Tascii output. For that reason, bentley@ submitted patches
to render "..." instead to groff in November 2014 (yes, more than
two years ago). Carsten Kunze yesterday merged them for the upcoming
groff-1.22.4 release. Yay!
Consequently, do the same in mandoc: Render \(Lq and \(Rq (which
are used for .Do, .Dq, .Lb, and .St) as '"' in -Tascii output.
All other output modes including -Tutf8 remain unchanged.
Ingo Schwarze [Fri, 17 Feb 2017 14:40:28 +0000 (14:40 +0000)]
Make the directory explicit where source files are located.
This is simple and seems to help the NetBSD build infrastructure.
From Christos Zoulas <christos at NetBSD>.
Ingo Schwarze [Fri, 17 Feb 2017 03:03:03 +0000 (03:03 +0000)]
Fix a read buffer overrun that copied random data from memory into
text nodes when a string passed to deroff() ended in a backslash
and the byte after the terminating NUL was non-NUL, found by tb@
with afl(1).
Invalid bytes so copied with the high bit set could later sometimes
trigger another out of bounds read access to static memory in
roff_strdup(), so add an assertion there to abort safely in case
of similar data corruption.
Ingo Schwarze [Thu, 16 Feb 2017 14:38:12 +0000 (14:38 +0000)]
Surprisingly, groff does not support scaling units in .Bl -column
column width specifiers, so stop supporting them, too.
As a side effect, this fixes an assertion failure that tb@ found
with afl(1), triggered by: .Bl -column -4n
Ingo Schwarze [Thu, 16 Feb 2017 10:56:07 +0000 (10:56 +0000)]
Fix rev. 1.280: -O syntax is different in default apropos(1) output
mode and in other output modes, so do not error out prematurely.
Also sort local variables in main() while here.
Ingo Schwarze [Thu, 16 Feb 2017 09:47:31 +0000 (09:47 +0000)]
Fix block scoping error if an explicit block is broken by two
implicit blocks (.Aq Bq Po .Pc) that left the outer breaker open
and could in exceptional cases, like between .Bl and .It, cause
tree corruption leading to NULL dereference.
Found by tb@ with afl(1).
While here, do not mark intermediate ENDBODY markers as broken.
Ingo Schwarze [Wed, 15 Feb 2017 15:58:46 +0000 (15:58 +0000)]
Style improvement, no functional change.
As reported by Yuri Pankov, some versions of GCC whine that "tmp"
might be used uninitialized in fts_open(3). Clearly, that cannot
actually happen, but explicitly setting it to NULL is safer anyway.
While here, rename the badly named variable "tmp" and make the
inner "if" easier to understand.
Ingo Schwarze [Wed, 15 Feb 2017 14:10:08 +0000 (14:10 +0000)]
Fix previous: I forgot that i had to change the convention how
a node is marked as "not a macro" when unifying the parsers.
Confirmed to work by Sevan Janiyan.
Ingo Schwarze [Sat, 11 Feb 2017 21:49:50 +0000 (21:49 +0000)]
Do not read one element past the end of the static const termacts array.
Bug found by Sevan Janiyan <venture37 at geeklan dot co dot uk>
who ran the OpenBSD mandoc test suite on Ubuntu on POWER8 (sic!)
and reported that mdoc/Sh/before.in failed in -Tman mode.
If that isn't power testing, i don't know...