Skip to content

Commit ce22a15

Browse files
committed
Update the utf-8 decoder in the ICU extension to treat invalid sequences as codepoint 0xFFFD, matching the core. Report [bugs:/info/2026-06-03T04:04:46Z | 2026-06-03T04:04:46Z].
1 parent ca05e89 commit ce22a15

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

ext/icu/icu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ static const unsigned char icuUtf8Trans1[] = {
105105
while( (*zIn & 0xc0)==0x80 ){ \
106106
c = (c<<6) + (0x3f & *(zIn++)); \
107107
} \
108+
if( c<0x80 \
109+
|| (c&0xFFFFF800)==0xD800 \
110+
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
108111
}
109112

110113
#define SQLITE_ICU_SKIP_UTF8(zIn) \

test/icu.test

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ ifcapable icu {
141141
do_catchsql_test icu-5.5 {SELECT 'abc' REGEXP } {1 {incomplete input}}
142142
do_catchsql_test icu-5.6 {SELECT 'abc' REGEXP, 1} {1 {near ",": syntax error}}
143143

144-
do_malloc_test icu-6.10 -sqlbody {
144+
do_malloc_test icu-5.10 -sqlbody {
145145
SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04));
146146
}
147147
}
@@ -180,4 +180,21 @@ do_execsql_test icu-7.3 {
180180
SELECT char(0x100)=='a', char(0x100)=='a' COLLATE dflt, char(0x100)=='a' COLLATE prim;
181181
} {0 0 1}
182182

183+
#-------------------------------------------------------------------------
184+
reset_db
185+
do_execsql_test icu-8.1 {
186+
CREATE TABLE t1(x TEXT);
187+
INSERT INTO t1 VALUES('abcdefg');
188+
INSERT INTO t1 VALUES('1234567');
189+
}
190+
191+
do_execsql_test icu-8.2 {
192+
SELECT * FROM t1 WHERE x LIKE CAST(x'C0A5' AS TEXT);
193+
} {}
194+
195+
do_execsql_test icu-8.3 {
196+
SELECT * FROM t1 WHERE x LIKE CAST(x'C19F' AS TEXT) || 'bcdefg';
197+
} {}
198+
183199
finish_test
200+

0 commit comments

Comments
 (0)