mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 09:35:08 -07:00
[Oracle] Fix nesting-depth cap, tolerate unescaped control chars, lazy-parse review fixes
This commit is contained in:
parent
75d18e6e83
commit
084d22cd7f
3 changed files with 37 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue