summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-12-16 09:50:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-12-16 09:50:33 (GMT)
commit4cca4b0b1c3095ef64a4c8fa816dd27d52c4bdff (patch)
tree752997977f3afb408d13de2db3137cd3734de221 /generic
parenta06b13bb4aab729b83c704578bc69e280e6071f3 (diff)
parentedee881fb26816194a320932f55e095b077d0e94 (diff)
downloadtcl-4cca4b0b1c3095ef64a4c8fa816dd27d52c4bdff.zip
tcl-4cca4b0b1c3095ef64a4c8fa816dd27d52c4bdff.tar.gz
tcl-4cca4b0b1c3095ef64a4c8fa816dd27d52c4bdff.tar.bz2
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index ef32d29..ecf01da 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2505,6 +2505,13 @@ Utf32ToUtfProc(
} else {
ch = (src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
}
+ if (ch >= 0x10FFFF || (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)
+ && !Tcl_UniCharIsUnicode(ch))) {
+ if (STOPONERROR) {
+ result = TCL_CONVERT_SYNTAX;
+ break;
+ }
+ }
/*
* Special case for 1-byte utf chars for speed. Make sure we work with
@@ -2595,12 +2602,11 @@ UtfToUtf32Proc(
break;
}
len = TclUtfToUCS4(src, &ch);
- if (!Tcl_UniCharIsUnicode(ch)) {
+ if (!Tcl_UniCharIsUnicode(ch) && (((ch & ~0x7FF) == 0xD800) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT))) {
if (STOPONERROR) {
result = TCL_CONVERT_UNKNOWN;
break;
}
- ch = 0xFFFD;
}
src += len;
if (flags & TCL_ENCODING_LE) {
@@ -2798,12 +2804,11 @@ UtfToUtf16Proc(
break;
}
len = TclUtfToUCS4(src, &ch);
- if (!Tcl_UniCharIsUnicode(ch)) {
+ if (!Tcl_UniCharIsUnicode(ch) && (((ch & ~0x7FF) == 0xD800) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT))) {
if (STOPONERROR) {
result = TCL_CONVERT_UNKNOWN;
break;
}
- ch = 0xFFFD;
}
src += len;
if (flags & TCL_ENCODING_LE) {