Archived
json-schema: \d \w \s and their negations are written out as classes
\d \w \s \D \W \S were refused in a literal ("Unsupported regex escape") and copied raw into a
class, where GBNF cannot load them. Tool schemas use them freely: oh-my-pi's workpool tool sends
"\S" thirteen times, so with 0017 its requests got past the anchors and were refused here.
Each shorthand is written out as its ECMA-262 class before the scanner reads the pattern. The
negated forms leave out '"', '\' and the control characters and admit any JSON escape instead, so
a match cannot run past the closing quote; \s also admits \t \n \f \r. In a class a positive
shorthand becomes its ranges and [\s\S] and its kin become any text; a negated shorthand mixed into
a class is refused. vendor/patches/0018, vendor/UPSTREAM; gbnf_test cases, and sample_test's
"cannot spell" case moves from \d to \b.
This commit is contained in:
1 parent
52f47505c2
commit
dd56e1158d
5 files changed
+212
-5
No files matched your search
@@ -1108,11 +1108,12 @@ TEST(json_schema_refuses_what_it_cannot_actually_enforce) {
|
||||
"{\"$ref\":\"https://example.com/s.json#/x\"}", "root", &gbnf, &err) < 0);
|
||||
CHECK(!err.empty());
|
||||
|
||||
/* GBNF cannot spell \d. Copying it through would succeed here and produce a grammar that
|
||||
* fails to load, an internal error on a schema we accepted. */
|
||||
/* GBNF cannot spell \b. Copying it through would succeed here and produce a grammar that
|
||||
* fails to load, an internal error on a schema we accepted. (\d and its kin are written out
|
||||
* as classes since vendor patch 0018.) */
|
||||
err.clear();
|
||||
CHECK(grammar_from_json_schema(
|
||||
"{\"type\":\"string\",\"pattern\":\"^\\\\d+$\"}", "root", &gbnf, &err) < 0);
|
||||
"{\"type\":\"string\",\"pattern\":\"^a\\\\bb$\"}", "root", &gbnf, &err) < 0);
|
||||
CHECK(!err.empty());
|
||||
|
||||
/* A stray ']' is in NON_LITERAL_SET but claimed by no arm of the pattern scanner, so the
|
||||
|
||||
Reference in new issue
Block a user