Repository navigation
fix(jsonschema): emit unicode-safe patterns from concerto regexes - #301
Open
rishabhknowss wants to merge 1 commit into
Open
rishabhknowss wants to merge 1 commit into
rishabhknowss wants to merge 1 commit into
Conversation
Concerto regexes have no `u` flag, so their source may contain identity escapes such as `\<` that are invalid in unicode mode, which JSON Schema validators such as ajv use to compile `pattern`. Drop those redundant escapes when the source is not valid in unicode mode. Also compile every definition in the JSON Schema verification test, since ajv only compiles definitions that are referenced. Closes accordproject#300 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: rishabhknowss <rishabhrai1515@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #300
JSONSchemaVisitorcopied a concerto regex'ssourcestraight intopattern. concerto regexes have nouflag, but ajv compilespatternin unicode mode, so identity escapes like\<(used inagreement.cto) made the generated schema fail withInvalid escape.Changes
toUnicodeSafePattern(): if the source isn't valid with theuflag, drop backslashes before characters that don't need escaping (they match the same literal either way).\-is kept inside character classes. valid sources are returned unchanged.patternoutput.$ref, since ajv skips definitions nothing references (this is whyagreementpassed before). it fails on main withInvalid regular expression: /^[^\<\>]*$/u: Invalid escapeand passes with this fix.\<\>,\-outside a class, and an already-safe pattern.Flags
String(regex)invisitMapDeclaration) are left alone since fix(jsonschema): emit map property schemas directly and apply their key and value types #293 is already reworking them. happy to apply the same helper there once that lands.w3.org/2001/XMLSchema.xsdcan't be fetched; unrelated to this change.Related Issues
patternfrom concerto regex fails in ajv (unicode mode) #300Author Checklist
--signoffoption of git commit.mainfromfork:branchname🤖 Generated with Claude Code