URL: <https://savannah.gnu.org/bugs/?65320>
Summary: [pdf] doesn't guard control characters when emitting bookmark diversion Group: GNU roff Submitter: gbranden Submitted: Fri 16 Feb 2024 03:49:13 PM UTC Category: Macro - others/general Severity: 3 - Normal Item Group: Incorrect behaviour Status: In Progress Privacy: Public Assigned to: gbranden Open/Closed: Open Discussion Lock: Any Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Fri 16 Feb 2024 03:49:13 PM UTC By: G. Branden Robinson <gbranden> Alex Colomar [https://lists.gnu.org/archive/html/groff/2024-02/msg00039.html reported to the _groff_ list]: > here's [a warning] that I've only seen in -Tpdf. It might be a bug in > -Tpdf. > > troff:man7/path_resolution.7:135: warning: macro 'and' not defined > (possibly missing space after 'an') > make: *** [share/mk/build/pdf/troff.mk:22: > .tmp/man/man7/path_resolution.7.pdf.set] Error 1 > make: *** Deleting file '.tmp/man/man7/path_resolution.7.pdf.set' > > Here's a small reproducer: > > alx@debian:~/tmp$ cat dot.man > .TH dot 7 2024-02-16 dots-in-SS > .SH Foo > .SS . and .. > \&. and .. are special files. > alx@debian:~/tmp$ groff -man -Tutf8 dot.man >/dev/null > alx@debian:~/tmp$ groff -man -Tps dot.man >/dev/null > alx@debian:~/tmp$ groff -man -Tpdf dot.man >/dev/null > troff:dot.man:3: warning: macro 'and' not defined (possibly missing > space after 'an') I can reproduce this with groff 1.23.0 and Git HEAD. I believe the problem happens because this `nop` request is taking place inside a diversion (a "box" diversion, to be precise). Consequently when the diversion is later interpolated, it can include macro calls or requests, so the formatter recognizes the control character at the beginning of the (interpolated) input line. This causes the PDF bookmarks that are automatically constructed from the (sub)section heading texts to be susceptible to misinterpretation. If you check the PDF generated from your reproducer, you will see that the corresponding bookmark for the subsection is absent. The solution is to prevent a potential control character that starts the (sub)section heading text from appearing at the beginning of the (interpolated) input line. Thus we need a dummy character prefix. Proposed fix: diff --git a/tmac/pdf.tmac b/tmac/pdf.tmac index 54175434f..fe12d35da 100644 --- a/tmac/pdf.tmac +++ b/tmac/pdf.tmac @@ -253,7 +253,7 @@ .de pdfbookmark . tr \[em]- . nf . box pdf:clean -. nop \\$* +. nop \&\\$* . fl . box . chop pdf:clean _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?65320> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/