diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2014-05-27 18:24:42 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2014-05-27 18:24:42 +0000 |
commit | 7535acc4e3072709aacf5179e8e8e14200da4a17 (patch) | |
tree | defba92119266e297d36c9eebb62b09611d97d36 | |
parent | b653a4d00e6628810fe80cf6b895c78ea7ac0da0 (diff) | |
download | pcre-7535acc4e3072709aacf5179e8e8e14200da4a17.tar.gz |
Give error for \x{} and \o{}.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1481 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | pcre_compile.c | 7 | ||||
-rw-r--r-- | pcre_internal.h | 2 | ||||
-rw-r--r-- | pcreposix.c | 3 | ||||
-rw-r--r-- | testdata/testinput2 | 12 | ||||
-rw-r--r-- | testdata/testoutput2 | 17 |
6 files changed, 42 insertions, 2 deletions
@@ -43,6 +43,9 @@ Version 8.36 xx-xxx-2014 8. Fixed a bug that was incorrectly auto-possessifying \w+ in the pattern ^\w+(?>\s*)(?<=\w) which caused it not to match "test test". + +9. Give a compile-time error for \o{} (as Perl does) and for \x{} (which Perl + doesn't). Version 8.35 04-April-2014 diff --git a/pcre_compile.c b/pcre_compile.c index 5368e38..1234db0 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -549,6 +549,7 @@ static const char error_texts[] = "group name must start with a non-digit\0" /* 85 */ "parentheses are too deeply nested (stack check)\0" + "digits missing in \\x{} or \\o{}\0" ; /* Table to identify digits and hex digits. This is used when compiling @@ -1259,6 +1260,7 @@ else case CHAR_o: if (ptr[1] != CHAR_LEFT_CURLY_BRACKET) *errorcodeptr = ERR81; else + if (ptr[2] == CHAR_RIGHT_CURLY_BRACKET) *errorcodeptr = ERR86; else { ptr += 2; c = 0; @@ -1328,6 +1330,11 @@ else if (ptr[1] == CHAR_LEFT_CURLY_BRACKET) { ptr += 2; + if (*ptr == CHAR_RIGHT_CURLY_BRACKET) + { + *errorcodeptr = ERR86; + break; + } c = 0; overflow = FALSE; while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0) diff --git a/pcre_internal.h b/pcre_internal.h index 6e915a0..02d3ab1 100644 --- a/pcre_internal.h +++ b/pcre_internal.h @@ -2281,7 +2281,7 @@ enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, - ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERRCOUNT }; + ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERRCOUNT }; /* JIT compiling modes. The function list is indexed by them. */ diff --git a/pcreposix.c b/pcreposix.c index ed50619..80281ea 100644 --- a/pcreposix.c +++ b/pcreposix.c @@ -172,7 +172,8 @@ static const int eint[] = { REG_BADPAT, /* invalid range in character class */ REG_BADPAT, /* group name must start with a non-digit */ /* 85 */ - REG_BADPAT /* parentheses too deeply nested (stack check) */ + REG_BADPAT, /* parentheses too deeply nested (stack check) */ + REG_BADPAT /* missing digits in \x{} or \o{} */ }; /* Table of texts corresponding to POSIX error codes */ diff --git a/testdata/testinput2 b/testdata/testinput2 index 0a49603..81be076 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4064,4 +4064,16 @@ backtracking verbs. --/ /^\w+(?>\s*)(?<=\w)/BZ +/\othing/ + +/\o{}/ + +/\o{whatever}/ + +/\xthing/ + +/\x{}/ + +/\x{whatever}/ + /-- End of testinput2 --/ diff --git a/testdata/testoutput2 b/testdata/testoutput2 index d0880db..114817a 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -14165,4 +14165,21 @@ Failed: parentheses are too deeply nested (stack check) at offset 0 End ------------------------------------------------------------------ +/\othing/ +Failed: missing opening brace after \o at offset 1 + +/\o{}/ +Failed: digits missing in \x{} or \o{} at offset 1 + +/\o{whatever}/ +Failed: non-octal character in \o{} (closing brace missing?) at offset 3 + +/\xthing/ + +/\x{}/ +Failed: digits missing in \x{} or \o{} at offset 3 + +/\x{whatever}/ +Failed: non-hex character in \x{} (closing brace missing?) at offset 3 + /-- End of testinput2 --/ |