Skip to content

Commit 3d8f816

Browse files
committed
MySQL Bug 100292: UTF-8 DECODING FAILS IF THE FIRST BYTE IS 0XEF
1 parent 256a5af commit 3d8f816

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cdk/include/mysql/cdk/foundation/string.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ size_t str_decode(
283283
return 0;
284284

285285
using Transcoder = rapidjson::Transcoder<FROM, TO>;
286-
Mem_stream<char> bytes((const char*)beg, len);
287-
rapidjson::EncodedInputStream<FROM, Mem_stream<char> > input(bytes);
286+
Mem_stream<typename FROM::Ch> input((typename FROM::Ch*)beg, len);
288287
Str_stream<typename TO::Ch> output(out);
289288

290289
while(input.Peek() != '\0')
@@ -296,7 +295,7 @@ size_t str_decode(
296295
}
297296
}
298297

299-
return bytes.Tell();
298+
return input.Tell();
300299
}
301300

302301

devapi/tests/bugs-t.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,3 +821,19 @@ TEST_F(Bugs, bug29847865)
821821
EXPECT_EQ(foo.size(), bar.size());
822822
EXPECT_EQ(foo, bar);
823823
}
824+
825+
TEST_F(Bugs, bug31656092)
826+
{
827+
SKIP_IF_NO_XPLUGIN
828+
829+
//first byte is the same as utf BOM mark, however, a valid unicode
830+
string foo("\xef\xbc\x88");
831+
832+
string query;
833+
query = string(u"select '") + foo +string("'");
834+
Row r = get_sess().sql(query).execute().fetchOne();
835+
string bar = r.get(0);
836+
837+
EXPECT_EQ(foo.size(), bar.size());
838+
EXPECT_EQ(foo, bar);
839+
}

0 commit comments

Comments
 (0)