diff options
author | dgp <dgp@users.sourceforge.net> | 2011-03-06 04:49:16 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-03-06 04:49:16 (GMT) |
commit | d7a6d085200c6f5ac12f6f3b56ed0757001d7e98 (patch) | |
tree | 2a13ba6550e1211925ea9ff051ff6c94599a67a1 | |
parent | 488806d8839d64b73f12bbd2fbdd514dfcf8e63f (diff) | |
parent | baac10e49ca94237df87385935b6898ca2546543 (diff) | |
download | tcl-d7a6d085200c6f5ac12f6f3b56ed0757001d7e98.zip tcl-d7a6d085200c6f5ac12f6f3b56ed0757001d7e98.tar.gz tcl-d7a6d085200c6f5ac12f6f3b56ed0757001d7e98.tar.bz2 |
* generic/tclParse.c (TclParseBackslash): Correct trunction checks in
* tests/parse.test: \x and \u substitutions. [Bug 3200987]
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclParse.c | 4 | ||||
-rw-r--r-- | tests/parse.test | 38 |
3 files changed, 45 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2011-03-05 Don Porter <dgp@users.sourceforge.net> + + * generic/tclParse.c (TclParseBackslash): Correct trunction checks in + * tests/parse.test: \x and \u substitutions. [Bug 3200987] + 2011-01-26 Donal K. Fellows <dkf@users.sf.net> * doc/RegExp.3: [Bug 3165108]: Corrected documentation of description diff --git a/generic/tclParse.c b/generic/tclParse.c index 42b8a20..963fad6 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -851,7 +851,7 @@ TclParseBackslash( result = 0xb; break; case 'x': - count += TclParseHex(p+1, numBytes-1, &result); + count += TclParseHex(p+1, numBytes-2, &result); if (count == 2) { /* * No hexadigits -> This is just "x". @@ -866,7 +866,7 @@ TclParseBackslash( } break; case 'u': - count += TclParseHex(p+1, (numBytes > 5) ? 4 : numBytes-1, &result); + count += TclParseHex(p+1, (numBytes > 5) ? 4 : numBytes-2, &result); if (count == 2) { /* * No hexadigits -> This is just "u". diff --git a/tests/parse.test b/tests/parse.test index c3f05ab..b5211e7 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -1050,6 +1050,44 @@ test parse-19.4 {Bug 1115904: recursion limit in Tcl_EvalEx} -setup { interp delete i } -returnCodes error -match glob -result {too many nested*} +test parse-20.1 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 1 +} {- \\ 1 simple \\ 1 text \\ 0 u12345} +test parse-20.2 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 2 +} {- {\u} 1 word {\u} 1 backslash {\u} 0 12345} +test parse-20.3 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 3 +} {- {\u1} 1 word {\u1} 1 backslash {\u1} 0 2345} +test parse-20.4 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 4 +} {- {\u12} 1 word {\u12} 1 backslash {\u12} 0 345} +test parse-20.5 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 5 +} {- {\u123} 1 word {\u123} 1 backslash {\u123} 0 45} +test parse-20.6 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 6 +} {- {\u1234} 1 word {\u1234} 1 backslash {\u1234} 0 5} +test parse-20.7 {TclParseBackslash: truncated escape} testparser { + testparser {\u12345} 7 +} {- {\u12345} 1 word {\u12345} 2 backslash {\u1234} 0 text 5 0 {}} + +test parse-20.8 {TclParseBackslash: truncated escape} testparser { + testparser {\x12X} 1 +} {- \\ 1 simple \\ 1 text \\ 0 x12X} +test parse-20.9 {TclParseBackslash: truncated escape} testparser { + testparser {\x12X} 2 +} {- {\x} 1 word {\x} 1 backslash {\x} 0 12X} +test parse-20.10 {TclParseBackslash: truncated escape} testparser { + testparser {\x12X} 3 +} {- {\x1} 1 word {\x1} 1 backslash {\x1} 0 2X} +test parse-20.11 {TclParseBackslash: truncated escape} testparser { + testparser {\x12X} 4 +} {- {\x12} 1 word {\x12} 1 backslash {\x12} 0 X} +test parse-20.12 {TclParseBackslash: truncated escape} testparser { + testparser {\x12X} 5 +} {- {\x12X} 1 word {\x12X} 2 backslash {\x12} 0 text X 0 {}} + cleanupTests } |