diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-07-19 19:57:59 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-07-19 19:57:59 -0700 |
| commit | cc84c3d7916640b75ca4dc0785f9b1f417df1664 (patch) | |
| tree | 81af5d71f4376154796636307c1b9e74ebd91c66 /utils.c | |
| parent | 711fe47a7f651f38e090c9a20ecef11feba6f705 (diff) | |
Made escape sequence handling stricter: no longer supporting arbitrary
characters, only special escapes like \n, hex sequences like \x0a, octal
sequences like \012, and backslashes \\
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -88,7 +88,7 @@ char unescapechar(const char *escaped, const char **end) case 'a': ret = '\a'; break; case 'b': ret = '\b'; break; case 'n': ret = '\n'; break; case 'r': ret = '\r'; break; case 't': ret = '\t'; break; case 'v': ret = '\v'; break; - case 'e': ret = '\033'; break; + case 'e': ret = '\033'; break; case '\\': ret = '\\'; break; case 'x': { // Hex static const unsigned char hextable[255] = { ['0']=0x10, ['1']=0x1, ['2']=0x2, ['3']=0x3, ['4']=0x4, @@ -114,7 +114,10 @@ char unescapechar(const char *escaped, const char **end) } break; } - default: break; + default: { + if (end) *end = escaped; + return (char)0; + } } if (end) *end = &escaped[len]; return (char)ret; |
