Repository navigation
Allow apostrophe in uri-template literal - #1275
Merged
Merged
Conversation
The uri-template format regex listed ' in its excluded character set, so "a'b" was reported invalid. An apostrophe in a literal is valid; remove it from the exclusion set.
There was a problem hiding this comment.
Pull request overview
This PR fixes uri-template format validation to accept apostrophes (') in URI-template literals, aligning the validator’s regex with RFC 6570 behavior and the JSON-Schema-Test-Suite expectation.
Changes:
- Updates the
uri-templateformat regex to stop excluding'in literals. - Adds a regression test ensuring
"a'b"validates underformat: "uri-template". - Verifies expression syntax (e.g.
"http://x/{y}") remains valid under the same format assertion settings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/com/networknt/schema/format/Formats.java | Removes ' from the excluded literal character set in the uri-template validation regex. |
| src/test/java/com/networknt/schema/FormatValidatorTest.java | Adds a regression test covering apostrophes in literals and a sanity check for expression syntax. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ravismash
added a commit
to ravismash/json-schema-validator
that referenced
this pull request
Nov 9, 2026
Formats.java and UriTemplateFormatTest are again identical to networknt#1385: runs of literal characters and varchars are matched possessively, so long templates no longer overflow the stack, and the tests add long-input and stray brace or percent sign cases. The two FormatValidatorTest cases are removed, as UriTemplateFormatTest covers the same inputs. The CHANGELOG entry names 2.0.8 and links networknt#1387, networknt#1385 and networknt#1275, and a Fixed entry covers the stack overflow.
ravismash
added a commit
to ravismash/json-schema-validator
that referenced
this pull request
Nov 9, 2026
Port of networknt#1385 to 2.x, together with networknt#1275, which was not backported. The literal class lists RFC 6570 section 2.1's ranges (the ASCII characters, ucschar and iprivate). A space, a backslash, C1 controls, lone surrogates, noncharacters, U+FFF0 to U+FFFD and U+E0000 to U+E0FFF are rejected in a literal. The apostrophe is accepted, as in the JSON-Schema-Test-Suite and on master, so both branches agree on uri-template. The vendored uri-template.json suite files are updated.
ravismash
added a commit
to ravismash/json-schema-validator
that referenced
this pull request
Nov 9, 2026
Formats.java and UriTemplateFormatTest are again identical to networknt#1385: runs of literal characters and varchars are matched possessively, so long templates no longer overflow the stack, and the tests add long-input and stray brace or percent sign cases. The two FormatValidatorTest cases are removed, as UriTemplateFormatTest covers the same inputs. The CHANGELOG entry names 2.0.8 and links networknt#1387, networknt#1385 and networknt#1275, and a Fixed entry covers the stack overflow.
stevehu
pushed a commit
that referenced
this pull request
Nov 9, 2026
* Limit uri-template literals to RFC 6570 characters on 2.x Port of #1385 to 2.x, together with #1275, which was not backported. The literal class lists RFC 6570 section 2.1's ranges (the ASCII characters, ucschar and iprivate). A space, a backslash, C1 controls, lone surrogates, noncharacters, U+FFF0 to U+FFFD and U+E0000 to U+E0FFF are rejected in a literal. The apostrophe is accepted, as in the JSON-Schema-Test-Suite and on master, so both branches agree on uri-template. The vendored uri-template.json suite files are updated. * Address review: re-port the #1385 review fixes, CHANGELOG links Formats.java and UriTemplateFormatTest are again identical to #1385: runs of literal characters and varchars are matched possessively, so long templates no longer overflow the stack, and the tests add long-input and stray brace or percent sign cases. The two FormatValidatorTest cases are removed, as UriTemplateFormatTest covers the same inputs. The CHANGELOG entry names 2.0.8 and links #1387, #1385 and #1275, and a Fixed entry covers the stack overflow. * Address review: drop "as on master" from the CHANGELOG entry
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.
The
uri-templateformat rejects an apostrophe in a literal:The regex's excluded character class lists
'. An apostrophe in a literal is valid (JSON-Schema-Test-Suiteuri-template.json: "an apostrophe in a literal is valid"; the reference validator agrees). Removed'from the exclusion set. Full suite stays green; added a test.