summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclCompExpr.c32
-rw-r--r--generic/tclParse.c18
-rw-r--r--tests/parse.test3
-rw-r--r--tests/parseExpr.test6
4 files changed, 25 insertions, 34 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 9142e2b..dde4e56 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1969,31 +1969,23 @@ ParseLexeme(
}
}
- if (Tcl_UtfCharComplete(start, numBytes)) {
- scanned = Tcl_UtfToUniChar(start, &ch);
- } else {
- char utfBytes[TCL_UTF_MAX];
- memcpy(utfBytes, start, (size_t) numBytes);
- utfBytes[numBytes] = '\0';
- scanned = Tcl_UtfToUniChar(utfBytes, &ch);
- }
- if (!isalnum(UCHAR(ch))) {
- *lexemePtr = INVALID;
- Tcl_DecrRefCount(literal);
- return scanned;
- }
- end = start;
- while (isalnum(UCHAR(ch)) || (UCHAR(ch) == '_')) {
- end += scanned;
- numBytes -= scanned;
- if (Tcl_UtfCharComplete(end, numBytes)) {
- scanned = Tcl_UtfToUniChar(end, &ch);
+ if (!isalnum(UCHAR(*start))) {
+ if (Tcl_UtfCharComplete(start, numBytes)) {
+ scanned = Tcl_UtfToUniChar(start, &ch);
} else {
char utfBytes[TCL_UTF_MAX];
- memcpy(utfBytes, end, (size_t) numBytes);
+ memcpy(utfBytes, start, (size_t) numBytes);
utfBytes[numBytes] = '\0';
scanned = Tcl_UtfToUniChar(utfBytes, &ch);
}
+ *lexemePtr = INVALID;
+ Tcl_DecrRefCount(literal);
+ return scanned;
+ }
+ end = start;
+ while (numBytes && (isalnum(UCHAR(*end)) || (UCHAR(*end) == '_'))) {
+ end += 1;
+ numBytes -= 1;
}
*lexemePtr = BAREWORD;
if (literalPtr) {
diff --git a/generic/tclParse.c b/generic/tclParse.c
index e475fb8..90ec43d 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -1344,8 +1344,7 @@ Tcl_ParseVarName(
Tcl_Token *tokenPtr;
register const char *src;
unsigned char c;
- int varIndex, offset;
- Tcl_UniChar ch;
+ int varIndex;
unsigned array;
if ((numBytes == 0) || (start == NULL)) {
@@ -1428,19 +1427,10 @@ Tcl_ParseVarName(
tokenPtr->numComponents = 0;
while (numBytes) {
- if (Tcl_UtfCharComplete(src, numBytes)) {
- offset = Tcl_UtfToUniChar(src, &ch);
- } else {
- char utfBytes[TCL_UTF_MAX];
-
- memcpy(utfBytes, src, (size_t) numBytes);
- utfBytes[numBytes] = '\0';
- offset = Tcl_UtfToUniChar(utfBytes, &ch);
- }
- c = UCHAR(ch);
+ c = UCHAR(*src);
if (isalnum(c) || (c == '_')) { /* INTL: ISO only, UCHAR. */
- src += offset;
- numBytes -= offset;
+ src += 1;
+ numBytes -= 1;
continue;
}
if ((c == ':') && (numBytes != 1) && (src[1] == ':')) {
diff --git a/tests/parse.test b/tests/parse.test
index d7de5ff..cd02386 100644
--- a/tests/parse.test
+++ b/tests/parse.test
@@ -656,6 +656,9 @@ test parse-12.24 {Tcl_ParseVarName procedure, missing close paren in array refer
test parse-12.25 {Tcl_ParseVarName procedure, nested array reference} testparser {
testparser {$x(a$y(b$z))} 0
} {- {$x(a$y(b$z))} 1 word {$x(a$y(b$z))} 8 variable {$x(a$y(b$z))} 7 text x 0 text a 0 variable {$y(b$z)} 4 text y 0 text b 0 variable {$z} 1 text z 0 {}}
+test parse-12.26 {Tcl_ParseVarName [d2ffcca163] non-ascii} testparser {
+ testparser "$\u0433" -1
+} "- {$\u0433} 1 word {$\u0433} 2 text {$} 0 text \u0433 0 {}"
test parse-13.1 {Tcl_ParseVar procedure} testparsevar {
set abc 24
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
index c1c489b..3e0df29 100644
--- a/tests/parseExpr.test
+++ b/tests/parseExpr.test
@@ -1051,6 +1051,12 @@ test parseExpr-22.18 {Bug 3401704} -constraints testexprparser -body {
testexprparser 0b02 -1
} -returnCodes error -match glob -result {*invalid binary number*}
+test parseExpr-22.19 {Bug d2ffcca163} -constraints testexprparser -body {
+ testexprparser \u0433 -1
+} -returnCodes error -match glob -result {*invalid character*}
+test parseExpr-22.20 {Bug d2ffcca163} -constraints testexprparser -body {
+ testexprparser \u043f -1
+} -returnCodes error -match glob -result {*invalid character*}
# cleanup
cleanupTests