Fix parsing of unicode escape sequences
Change-Id: I63a7cd3a571fb47c97157bcb2ca29c4239c600ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7ae6a6e744
commit
53bbea2328
@ -584,9 +584,9 @@ static inline bool addHexDigit(char digit, uint *result)
|
||||
if (digit >= '0' && digit <= '9')
|
||||
*result |= (digit - '0');
|
||||
else if (digit >= 'a' && digit <= 'f')
|
||||
*result |= (digit - 'a');
|
||||
*result |= (digit - 'a') + 10;
|
||||
else if (digit >= 'A' && digit <= 'F')
|
||||
*result |= (digit - 'A');
|
||||
*result |= (digit - 'A') + 10;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
|
Binary file not shown.
@ -115,6 +115,8 @@ private Q_SLOTS:
|
||||
void testCompaction();
|
||||
void testDebugStream();
|
||||
void testCompactionError();
|
||||
|
||||
void parseUnicodeEscapes();
|
||||
private:
|
||||
QString testDataDir;
|
||||
};
|
||||
@ -1758,5 +1760,19 @@ void TestQtJson::testCompactionError()
|
||||
}
|
||||
}
|
||||
|
||||
void TestQtJson::parseUnicodeEscapes()
|
||||
{
|
||||
const QByteArray json = "[ \"A\\u00e4\\u00C4\" ]";
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(json);
|
||||
QJsonArray array = doc.array();
|
||||
|
||||
QString result = QLatin1String("A");
|
||||
result += QChar(0xe4);
|
||||
result += QChar(0xc4);
|
||||
|
||||
QCOMPARE(array.first().toString(), result);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestQtJson)
|
||||
#include "tst_qtjson.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user