fix bug in json_writer
Ruler stores null-terminated strings in fixed length char arrays, so when creating a JSON a string might end earlier that it's size sugsests. Change-Id: Icdcaf35f9ce54c24dcd36368dc49bb688a2a65ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150542 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins
This commit is contained in:
committed by
Miklos Vajna
parent
f62b1e17de
commit
2fe581d916
@@ -236,7 +236,8 @@ void JsonWriter::put(std::string_view pPropName, std::string_view rPropVal)
|
|||||||
++mPos;
|
++mPos;
|
||||||
|
|
||||||
// copy and perform escaping
|
// copy and perform escaping
|
||||||
for (size_t i = 0; i < rPropVal.size(); ++i)
|
bool bReachedEnd = false;
|
||||||
|
for (size_t i = 0; i < rPropVal.size() && !bReachedEnd; ++i)
|
||||||
{
|
{
|
||||||
char ch = rPropVal[i];
|
char ch = rPropVal[i];
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@@ -251,6 +252,9 @@ void JsonWriter::put(std::string_view pPropName, std::string_view rPropVal)
|
|||||||
case '\\':
|
case '\\':
|
||||||
writeEscapedSequence(ch, mPos);
|
writeEscapedSequence(ch, mPos);
|
||||||
break;
|
break;
|
||||||
|
case 0:
|
||||||
|
bReachedEnd = true;
|
||||||
|
break;
|
||||||
case '\xE2': // Special processing of U+2028 and U+2029
|
case '\xE2': // Special processing of U+2028 and U+2029
|
||||||
if (i + 2 < rPropVal.size() && rPropVal[i + 1] == '\x80'
|
if (i + 2 < rPropVal.size() && rPropVal[i + 1] == '\x80'
|
||||||
&& (rPropVal[i + 2] == '\xA8' || rPropVal[i + 2] == '\xA9'))
|
&& (rPropVal[i + 2] == '\xA8' || rPropVal[i + 2] == '\xA9'))
|
||||||
|
Reference in New Issue
Block a user