[Oracle] Fix nesting-depth cap, tolerate unescaped control chars, lazy-parse review fixes

This commit is contained in:
Lukas Brübach 2026-09-02 15:04:38 +02:00 committed by GitHub
parent 75d18e6e83
commit 084d22cd7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 9 deletions

View file

@ -551,7 +551,6 @@ int OracleImporter::startImport()
{
static ICardSetPriorityController *noOpController = new NoopCardSetPriorityController();
<<<<<<< HEAD
// Pre-allocate the cards hash to avoid rehashing during import. Keys are
// distinct card names while raw ranges only count printings (AllPrintings
// ~100k printings vs ~35k names), so this over-reserves somewhat; an exact

View file

@ -213,9 +213,10 @@ bool decodeString(const char *&p, const char *end, QString &out)
flush();
return true;
}
if (static_cast<unsigned char>(c) < 0x20) {
return false; // unescaped control character is invalid JSON
}
// Deliberately accept unescaped control characters (e.g. a tab inside
// a set name): QJsonDocument and skipString accept them too, so
// rejecting them here would fail the whole document on a byte that
// Qt is fine with — the very total-failure mode this scanner avoids.
utf8 += c;
++p;
}
@ -399,20 +400,19 @@ bool skipArray(const char *&p, const char *end, int depth)
bool skipValue(const char *&p, const char *end, int depth)
{
if (depth <= 0) {
return false; // nest deeper than the cap
}
p = skipWhitespace(p, end);
if (p >= end) {
return false;
}
const char c = *p;
if (c == '{') {
return skipObject(p, end, depth - 1);
// pass depth through: skipObject consumes the single decrement for this level
return skipObject(p, end, depth);
}
if (c == '[') {
return skipArray(p, end, depth - 1);
return skipArray(p, end, depth);
}
// a primitive is a leaf, so it never wastes a nesting level
return skipPrimitive(p, end);
}