bugGNU roff - Bugs: bug #64104, [troff] you can set the escape,...

 
 

bug #64104: [troff] you can set the escape, control, and no-break control characters to the same thing

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Mon 24 Apr 2023 10:08:22 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 10 Jul 2023 08:38:51 AM UTC, comment #6: 


commit 1e8e7608414ec18e94afaebd74c4897ed7f866bd
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun May 7 00:32:32 2023 -0500

    [troff]: Fix Savannah #64104 (1/2).

    * src/roff/troff/input.cpp (set_escape_char): Rename this...
      (assign_escape_character): ...to this.  Don't permit the escape
      character to be set to the same thing as the control or no-break
      control characters.

    * doc/groff.texi (Using Escape Sequences): Document restrictions.

    Tested with:

    $ cat ec.roff
    .ec .
    .ec '
    .ec \-
    $ ./build/test-groff ec.roff
    troff:ec.roff:1: error: ignoring escape character change request; the control character is already '.'
    troff:ec.roff:2: error: ignoring escape character change request; the no-break control character is already "'"
    troff:ec.roff:3: error: cannot select invalid escape character; using '\'

commit e09bc6c083657af9b503313376a759e674ecfbaf
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun May 7 12:33:20 2023 -0500

    [troff]: Fix Savannah #64104 (2/2).

    * src/roff/troff/env.h (class environment): Slightly refactor.  Rename
      fields `control_char` and `no_break_control_char` to
      `control_character` and `no_break_control_character`, respectively,
      and make them private.  Add public getters and setters for them.

      (get_control_character): New public member function returns `unsigned
      char`.

      (set_control_character): New public member function takes an `unsigned
      char` and returns a `bool`.

      (get_no_break_control_character):
      (set_no_break_control_character): Similar.

    * src/roff/troff/env.cpp (environment::environment): Update constructors
      to use new field names and initialize them in their new order of
      declaration.

      (environment::copy): Similar.  (Not to be confused with a copy
      constructor, this member function implements the operation of a valid
      `evc` GNU troff request.)

      (environment::get_control_character):
      (environment::set_control_character):
      (environment::get_no_break_control_character):
      (environment::set_no_break_control_character): Implement.

    * src/roff/troff/env.cpp: Drop handling of `cc` and `c2` requests.

      (control_char, no_break_control_char): Drop implementations.

      (init_env_requests): Drop `init_request` calls for them.

    * src/roff/troff/input.cpp: Resurrect handling of `cc` and `c2` requests
      here, with more error handling.

      (assign_escape_character, process_input_stack): Use the new getters
      defined above in environment object since the relevant fields are now
      private.

      (assign_control_character): New function assumes the former
      responsibilities of env.cpp:control_char and rejects the request if
      the desired character is already the escape or no-break control
      character.

      (assign_no_break_control_character): New function assumes the former
      responsibilities of env.cpp:no_break_control_char and rejects the
      request if the desired character is already the escape or control
      character.

      (process_input_stack): Reorder comparisons to avoid inadvertent lvalue
      assignment.  Add parentheses to assignment with complex RHS.

      (init_input_requests): Attach `cc` and `c2` requests to new functions
      above.

    * doc/groff.texi (Control Characters): Document restrictions.

    Fixes <https://savannah.gnu.org/bugs/?64104>.

    Tested with:

    $ cat cc.roff
    .cc \\
    .cc '
    .cc \-
    $ ./build/test-groff cc.roff
    troff:cc.roff:1: error: ignoring control character change request; the escape character is already '\'
    troff:cc.roff:2: error: ignoring control character change request; the no-break control character is already "'"
    troff:cc.roff:3: error: cannot select invalid control character; using '.'
    $ cat c2.roff
    .c2 \\
    .c2 .
    .c2 \-
    $ ./build/test-groff c2.roff
    troff:c2.roff:1: error: ignoring no-break control character change request; the escape character is already '\'
    troff:c2.roff:2: error: ignoring no-break control character change request; the (breaking) control character is already '.'
    troff:c2.roff:3: error: cannot select invalid no-break control character; using "'"


G. Branden Robinson <gbranden>
Group administrator
Mon 22 May 2023 07:57:56 AM UTC, comment #5: 
G. Branden Robinson <gbranden>
Group administrator
Mon 08 May 2023 08:14:31 PM UTC, comment #4: 

In my working copy.


commit 3e8a20056e510b76733abcd9056d686f5b3b8ad0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun May 7 00:32:32 2023 -0500

    [troff]: Fix Savannah #64104 (1/2).

    * src/roff/troff/input.cpp (set_escape_char): Rename this...
      (assign_escape_character): ...to this.  Don't permit the escape
      character to be set to the same thing as the control or no-break
      control characters.

    * doc/groff.texi (Using Escape Sequences): Document restrictions.

    Tested with:

    $ cat ec.roff
    .ec .
    .ec '
    .ec \-
    $ ./build/test-groff ec.roff
    troff:ec.roff:1: error: ignoring escape character change request; the control character is already '.'
    troff:ec.roff:2: error: ignoring escape character change request; the no-break control character is already "'"
    troff:ec.roff:3: error: cannot select invalid escape character; using '\'

commit 25629b8d6dee38fb531fbe61e15190d77f359301
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun May 7 12:33:20 2023 -0500

    [troff]: Fix Savannah #64104 (2/2).

    * src/roff/troff/env.h (class environment): Slightly refactor.  Rename
      fields `control_char` and `no_break_control_char` to
      `control_character` and `no_break_control_character`, respectively,
      and make them private.  Add public getters and setters for them.

      (get_control_character): New public member function returns `unsigned
      char`.

      (set_control_character): New public member function takes an `unsigned
      char` and returns a `bool`.

      (get_no_break_control_character):
      (set_no_break_control_character): Similar.

    * src/roff/troff/env.cpp (environment::environment): Update constructors
      to use new field names and initialize them in their new order of
      declaration.

      (environment::copy): Similar.  (Not to be confused with a copy
      constructor, this member function implements the operation of a valid
      `evc` GNU troff request.)

      (environment::get_control_character):
      (environment::set_control_character):
      (environment::get_no_break_control_character):
      (environment::set_no_break_control_character): Implement.

    * src/roff/troff/env.cpp: Drop handling of `cc` and `c2` requests.

      (control_char, no_break_control_char): Drop implementations.

      (init_env_requests): Drop `init_request` calls for them.

    * src/roff/troff/input.cpp: Resurrect handling of `cc` and `c2` requests
      here, with more error handling.

      (assign_escape_character, process_input_stack): Use the new getters
      defined above in environment object since the relevant fields are now
      private.

      (assign_control_character): New function assumes the former
      responsibilities of env.cpp:control_char and rejects the request if
      the desired character is already the escape or no-break control
      character.

      (assign_no_break_control_character): New function assumes the former
      responsibilities of env.cpp:no_break_control_char and rejects the
      request if the desired character is already the escape or control
      character.

      (process_input_stack): Reorder comparisons to avoid inadvertent lvalue
      assignment.  Add parentheses to assignment with complex RHS.

      (init_input_requests): Attach `cc` and `c2` requests to new functions
      above.

    * doc/groff.texi (Control Characters): Document restrictions.

    Tested with:

    $ cat cc.roff
    .cc \\
    .cc '
    .cc \-
    $ ./build/test-groff cc.roff
    troff:cc.roff:1: error: ignoring control character change request; the escape character is already '\'
    troff:cc.roff:2: error: ignoring control character change request; the no-break control character is already "'"
    troff:cc.roff:3: error: cannot select invalid control character; using '.'
    $ cat c2.roff
    .c2 \\
    .c2 .
    .c2 \-
    $ ./build/test-groff c2.roff
    troff:c2.roff:1: error: ignoring no-break control character change request; the escape character is already '\'
    troff:c2.roff:2: error: ignoring no-break control character change request; the (breaking) control character is already '.'
    troff:c2.roff:3: error: cannot select invalid no-break control character; using "'"


G. Branden Robinson <gbranden>
Group administrator
Mon 24 Apr 2023 10:37:40 AM UTC, comment #3: 


.cc @
@c2 @
@tm foo
foo


That's wack, but "foo" goes to standard error as we expect.


$ cat ATTIC/all-wack.roff
.nr a 12345
.cc @
@c2 @
@ec @
@na
$ cd ~/heirloom
$ ./bin/nroff ~/src/GIT/groff/ATTIC/all-wack.roff | cat -s
12345

$ cd ~/dwb
$ DWBHOME=. ./bin/nroff ~/src/GIT/groff/ATTIC/all-wack.roff | cat -s
12345

$ popd # groff 1.22.4
$ nroff ATTIC/all-wack.roff|cat -s
12345


Well, at least they can all agree on that.  Still, I aim to reject this nonsense.

G. Branden Robinson <gbranden>
Group administrator
Mon 24 Apr 2023 10:11:05 AM UTC, comment #2: 

Missing word typo.

comment #1:

> Oh, also, we should bring the hammer down on trying to set the escape character to either of the control characters, if that hammer is NOT being dropped already.


Basically, when attempting to assign any one of these, check the other two.  IIRC no special case is required for the escape character being off; in that event it is stored as a NUL which will not compare identically to any proffered roff control character.

G. Branden Robinson <gbranden>
Group administrator
Mon 24 Apr 2023 10:09:03 AM UTC, comment #1: 

Oh, also, we should bring the hammer down on trying to set the escape character to either of the control characters, if that hammer is being dropped already.

G. Branden Robinson <gbranden>
Group administrator
Mon 24 Apr 2023 10:08:22 AM UTC, original submission:  

You can set the control and no-break control characters to the same thing.

If you try:

DWB and Heirloom treat `c2` as always winning; groff treats `cc` as always winning.


.c2 @
@cc @
foo
@br
bar
@pl \n(nlu



.cc @
@c2 @
foo
@br
bar
@pl \n(nlu


For both of the above inputs, groff produces


foo
bar


while DWB and Heirloom Doctools troff produce


foo bar


This should not be allowed.  Attempts should be diagnosed and ignored.  You can swap 'em or whatever, if you want, but they should never be the same.

Also, doing this breaks the interpretation of the `pl` request on both DWB and Heirloom.  No idea why.  Bugs dating back to the dawn of man, I reckon.

G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-10 gbranden StatusReady for Merge Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2023-05-22 gbranden StatusIn Progress Ready for Merge
    2023-05-08 gbranden StatusNone In Progress
        Assigned toNone gbranden
    2023-04-24 gbranden Summary[troff] you can set the control and no-break control characters to the same thing [troff] you can set the escape, control, and no-break control characters to the same thing

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code