common : fix json schema with '\' in literals (#17307)

* Fix json schema with '\' in literals

* Add "literal string with escapes" test
This commit is contained in:
Igor Smirnov
2025-11-29 21:06:32 +05:00
committed by GitHub
parent 7d2add51d8
commit 0874693b44
4 changed files with 32 additions and 6 deletions
+26
View File
@@ -1339,6 +1339,32 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
space ::= | " " | "\n"{1,2} [ \t]{0,20}
)"""
});
test({
SUCCESS,
"literal string with escapes",
R"""({
"properties": {
"code": {
"const": " \r \n \" \\ ",
"description": "Generated code",
"title": "Code",
"type": "string"
}
},
"required": [
"code"
],
"title": "DecoderResponse",
"type": "object"
})""",
R"""(
code ::= "\" \\r \\n \\\" \\\\ \"" space
code-kv ::= "\"code\"" space ":" space code
root ::= "{" space code-kv "}" space
space ::= | " " | "\n"{1,2} [ \t]{0,20}
)"""
});
}
int main() {