diff options
Diffstat (limited to 'mandoc.c')
-rw-r--r-- | mandoc.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -41,7 +41,7 @@ enum mandoc_esc mandoc_escape(const char **end, const char **start, int *sz) { const char *local_start; - int local_sz; + int local_sz, c, i; char term; enum mandoc_esc gly; @@ -330,8 +330,26 @@ mandoc_escape(const char **end, const char **start, int *sz) } break; case ESCAPE_SPECIAL: - if (1 == *sz && 'c' == **start) - gly = ESCAPE_NOSPACE; + if (**start == 'c') { + if (*sz == 1) { + gly = ESCAPE_NOSPACE; + break; + } + if (*sz < 6 || *sz > 7 || + strncmp(*start, "char", 4) != 0 || + (int)strspn(*start + 4, "0123456789") + 4 < *sz) + break; + c = 0; + for (i = 4; i < *sz; i++) + c = 10 * c + ((*start)[i] - '0'); + if (c < 0x21 || (c > 0x7e && c < 0xa0) || c > 0xff) + break; + *start += 4; + *sz -= 4; + gly = ESCAPE_NUMBERED; + break; + } + /* * Unicode escapes are defined in groff as \[u0000] * to \[u10FFFF], where the contained value must be |