Repository navigation
Read schema patterns as ECMAScript, as the browser does - #2557
Merged
Merged
Conversation
jsonschema searches `pattern` and `patternProperties` with Python's re, whose $ also matches before a final newline, so "abc\\n" passed ^[a-z]+$ at every Leaf boundary while the browser refused it. LeafValidator reads both with regress, an ECMAScript engine; check_schema refuses a pattern only Python reads; the three lookahead workarounds go back to $. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ve patternProperties to jsonschema Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 12, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Two regex paths still differ from the proposed ECMAScript contract. Both cases below reproduce on the current head.
jsonschema has no option for another engine, and its keywords make one call,
re.search, in two modules; point those at regress, so patternProperties and the
additionalProperties and unevaluatedProperties accounting read keys as the
browser does, and hold check_schema's regex format to the same engine, so an
ECMAScript-only pattern such as \\p{L} is admitted and a Python-only one refused.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
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.
JSON Schema defines
patternas an ECMAScript regular expression, and the browser reads it that way, but jsonschema searches it with Python'sre, whose$also matches before a final newline. So every^…$pattern at every Leaf boundary admitted a trailing newline:"abc\n"passed^[a-z]+$for element ids, reaction tokens, data-contract names and the rest. #2507 hit this and ended three patterns with a lookahead; this fixes it where every reader gets its validator.re.search, in two private modules (_keywords,_utils).registry/schema.pypoints that call at regress, an ECMAScript engine (Rust, compiled), with theuflag JSON Schema recommends. That coverspattern,patternProperties, and theadditionalProperties/unevaluatedPropertiesaccounting built on them, in every validator, a nested$schemaincluded. A call jsonschema later adds to those modules fails loudly rather than reading Python's dialect;uv.lockpins the version the suite passed on.check_schemaholds the metaschema'sregexformat to the same engine, so an ECMAScript pattern Python refuses (\p{L},(?<name>…)) is admitted and a Python-only one ((?P<name>…)) refused. All 40 distinct patterns in the tree compile.(?![\s\S])workarounds from Cut Python rechecks a stronger mechanism already enforces, and refuse a reply to a withdrawn message #2507 are plain$again, andregistry/layer.py's one directDraft202012Validatorgoes throughjson_validator.regress>=2026.9, documented inpyproject.tomlbesideada-url.Behavior change: a string with a trailing newline no longer passes an anchored pattern, and a registry declaring a Python-only pattern is refused at
page check/package check.