Commit 8a4fd1c5 authored by Volker Krause's avatar Volker Krause
Browse files

Work around another variant of invalid JSON

This time it's extra commas at the end of objects, brought to you by
Eventbrite. So far their emails contained valid JSON, but the affected
one does not contain a location, so possibly breaking their template.
parent 9442c08d
Pipeline #42340 passed with stage
in 8 minutes and 27 seconds
<html>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EventReservation",
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/Confirmed",
"reservationFor": {
"@type": "Event",
"name": "XMAS Open Mobility Data Community Remote Meetup 2020 #xomdcrm20",
"startDate": "2020-12-11T17:00:00+01:00",
"endDate": "2020-12-12T17:00:00+01:00",
}
}
</script>
</html>
[
{
"@context": "http://schema.org",
"@type": "EventReservation",
"reservationFor": {
"@type": "Event",
"endDate": "2020-12-12T17:00:00+01:00",
"name": "XMAS Open Mobility Data Community Remote Meetup 2020 #xomdcrm20",
"startDate": "2020-12-11T17:00:00+01:00"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/Confirmed"
}
]
...@@ -37,6 +37,18 @@ static QByteArray fixupJson(const QByteArray &data) ...@@ -37,6 +37,18 @@ static QByteArray fixupJson(const QByteArray &data)
output.append("]"); output.append("]");
} }
// Eventbrite adds commas where there shouldn't be one...
for (int idx = output.indexOf("\",\n"); idx > 0 && idx + 3 < output.size(); idx = output.indexOf("\",\n", idx)) {
const auto comma = idx + 1;
idx += 3;
while (idx < output.size() && std::isspace(output[idx])) {
++idx;
}
if (idx < output.size() && output[idx] == '}') {
output[comma] = ' ';
}
}
return output; return output;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment