]> git.cameronkatri.com Git - mandoc.git/commitdiff
Allow arbitrary argument delimiters for \C, like groff does.
authorIngo Schwarze <schwarze@openbsd.org>
Mon, 6 Jun 2022 12:09:48 +0000 (12:09 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Mon, 6 Jun 2022 12:09:48 +0000 (12:09 +0000)
The restriction of only allowing ' as the delimiter was introduced
by kristaps@ on 2011/04/09 when he first supported \C.
For most other escape sequences, similar restrictions were relaxed
later on, but for the rarely used \C, it was apparently forgotten.

While here, reject empty character names: they are never valid.

roff_escape.c

index 777d753bc0d29f8db039d9d1af46d3326f741e3e..39d57e885996f79dc997f086edeee4d744edd622 100644 (file)
@@ -206,10 +206,6 @@ roff_escape(const char *buf, const int ln, const int aesc,
                term = '\b';
                break;
        case 'C':
-               if (buf[iarg] != '\'') {
-                       rval = ESCAPE_ERROR;
-                       goto out;
-               }
                rval = ESCAPE_SPECIAL;
                term = '\b';
                break;
@@ -391,6 +387,11 @@ roff_escape(const char *buf, const int ln, const int aesc,
                break;
 
        case ESCAPE_SPECIAL:
+               if (argl == 0) {
+                       err = MANDOCERR_ESC_BADCHAR;
+                       rval = ESCAPE_ERROR;
+                       break;
+               }
 
                /*
                 * The file chars.c only provides one common list of