gbranden pushed a commit to branch master
in repository groff.

commit fec01442ebfc5653c60b26e73fde1cb8988426bc
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 28 17:10:54 2025 -0600

    [troff]: Fix Savannah #67744.
    
    * src/roff/troff/input.cpp (read_delimited_name): Stop accepting
      horizontal motion tokens as escape sequence delimiters.  This to
      prohibit use of the delimited `\h` escape sequence as a delimiter, but
      because of GNU troff's internal design, also prohibits the
      parameterless `\0`, `\^`, and `\|` delimiters.
    
    * doc/groff.texi.in (Delimiters):
    * man/groff.7.man (Delimiters): De-document support for these
      delimiters.
    
    * NEWS: Report change.
    
    Fixes <https://savannah.gnu.org/bugs/?67744>.  The problem of acceptance
    of `\h` as an escape sequence delimiter appears to date back to groff's
    birth.  (`get_delim_name()` didn't check for any token types except EOF
    and newline.)
---
 ChangeLog                | 19 +++++++++++++++++++
 NEWS                     |  4 ++++
 doc/groff.texi.in        |  5 +----
 man/groff.7.man          |  5 +----
 src/roff/troff/input.cpp |  5 +++--
 5 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 856a4ded2..7ca6c700f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2025-11-28  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (read_delimited_name): Stop accepting
+       horizontal motion tokens as escape sequence delimiters.  This to
+       prohibit use of the delimited `\h` escape sequence as a
+       delimiter, but because of GNU troff's internal design, also
+       prohibits the parameterless `\0`, `\^`, and `\|` delimiters.
+
+       * doc/groff.texi.in (Delimiters):
+       * man/groff.7.man (Delimiters): De-document support for these
+       delimiters.
+
+       * NEWS: Report change.
+
+       Fixes <https://savannah.gnu.org/bugs/?67744>.  The problem of
+       acceptance of `\h` as an escape sequence delimiter appears to
+       date back to groff's birth.  (`get_delim_name()` didn't check
+       for any token types except EOF and newline.)
+
 2025-11-28  G. Branden Robinson <[email protected]>
 
        * src/roff/groff/tests/check-delimiter-validity.sh:
diff --git a/NEWS b/NEWS
index f3cbcf7ae..47403a7d2 100644
--- a/NEWS
+++ b/NEWS
@@ -116,6 +116,10 @@ troff
    parameterized escape sequences `\A`, `\b`, `\o`, `\w`, `\X`, and
    `\Z`.
 
+*  GNU troff no longer accepts `\0`, `\^`, and `\|` as escape sequence
+   delimiters; doing so inadvertently permited the delimited `\h` escape
+   sequence to serve as delimiter to another delimited escape sequence.
+
 *  The `color`, `cp`, `kern`, `linetabs`, and `vpt` requests now
    interpret arguments with negative values as instructions to disable
    the corresponding feature, using the *roff integer-to-Boolean
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index fcc3b23bd..fa3e9d0a9 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -7823,8 +7823,6 @@ and thus are allowed as delimiters:
 @c original input.
 @code{\@key{SPC}},
 @code{\%},
-@code{\|},
-@code{\^},
 @code{\@{},
 @code{\@}},
 @code{\'},
@@ -7839,7 +7837,6 @@ and thus are allowed as delimiters:
 @code{\&},
 @code{\:},
 @code{\~},
-@code{\0},
 @code{\a},
 @code{\c},
 @code{\d},
@@ -7851,7 +7848,7 @@ and thus are allowed as delimiters:
 and
 @code{\u}.
 However,
-using them this way is discouraged;
+we discourage using them this way;
 they can make the input confusing to read.
 
 @cindex @code{\D}, delimiters allowed by
diff --git a/man/groff.7.man b/man/groff.7.man
index 4cfb2e39b..c334996cc 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -1881,8 +1881,6 @@ and thus are allowed as delimiters:
 .BI \[rs] space\c
 ,
 .BR \[rs]% ,
-.BR \[rs]| ,
-.BR \[rs]\[ha] ,
 .BR \[rs]{ ,
 .BR \[rs]} ,
 .BR \[rs]\[aq] ,
@@ -1897,7 +1895,6 @@ and thus are allowed as delimiters:
 .BR \[rs]& ,
 .BR \[rs]: ,
 .BR \[rs]\[ti] ,
-.BR \[rs]0 ,
 .BR \[rs]a ,
 .BR \[rs]c ,
 .BR \[rs]d ,
@@ -1910,7 +1907,7 @@ and
 .BR \[rs]u .
 .
 However,
-using them this way is discouraged;
+we discourage using them this way;
 they can make the input confusing to read.
 .
 .
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 35224c502..4ba8539a5 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6146,8 +6146,9 @@ static symbol read_delimited_name()
     error("end of input at start of delimited name");
     return NULL_SYMBOL;
   }
-  if (start_token.is_newline()) {
-    error("a newline is not allowed to delimit a name");
+  if (start_token.is_newline() || start_token.is_horizontal_space()) {
+    error("%1 is not allowed to delimit a name",
+         start_token.description());
     return NULL_SYMBOL;
   }
   int start_level = input_stack::get_level();

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to