gbranden pushed a commit to branch master
in repository groff.
commit 33e1823ed0df56d95d26d03f4f11204a48be45be
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Aug 23 00:17:57 2024 -0500
[troff]: Don't write nulls in device control cmds.
* src/roff/troff/input.cpp (device_request): Don't write null characters
to device control command commands (`x X` in device-independent
output). These can occur if one interpolates a diversion into the
argument of a `device` request.
---
ChangeLog | 7 +++++++
src/roff/troff/input.cpp | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 46a2fbec2..a0deec013 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2024-08-23 G. Branden Robinson <[email protected]>
+ * src/roff/troff/input.cpp (device_request): Don't write null
+ characters to device control command commands (`x X` in
+ device-independent output). These can occur if one interpolates
+ a diversion into the argument of a `device` request.
+
+2024-08-24 G. Branden Robinson <[email protected]>
+
* tmac/pdf.tmac (pdfbookmark): Trivially refactor. Rename
`pdf:cleaned` string to `pdf:title` to reflect (1) its use in
the emitted PDF device control command and (2) the fact that it
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 93d7b4918..732185645 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5801,7 +5801,11 @@ static void device_request()
}
if (curdiv == topdiv && topdiv->before_first_page)
topdiv->begin_page();
- for (; c != '\n' && c != EOF; c = get_copy(0 /* nullptr */))
+ // Null characters can correspond to node types like vmotion_node that
+ // are unrepresentable in a device control command, and got scrubbed
+ // by `asciify`.
+ for (; c != '\0' && c != '\n' && c != EOF;
+ c = get_copy(0 /* nullptr */))
mac.append(c);
curenv->add_node(new special_node(mac));
tok.next();
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit