Skip to content

Allow apostrophe in uri-template literal - #1275

Merged
stevehu merged 1 commit into
networknt:masterfrom
dngr2:uri-template-allow-apostrophe
Aug 26, 2026
Merged

stevehu merged 1 commit into
networknt:masterfrom
dngr2:uri-template-allow-apostrophe

Conversation

@dngr2

@dngr2 dngr2 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The uri-template format rejects an apostrophe in a literal:

"a'b"   // reported invalid — should be valid

The regex's excluded character class lists '. An apostrophe in a literal is valid (JSON-Schema-Test-Suite uri-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.

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.
@stevehu
stevehu requested a lite review from Copilot August 20, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-template format regex to stop excluding ' in literals.
  • Adds a regression test ensuring "a'b" validates under format: "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.

@stevehu
stevehu merged commit 2a28f87 into networknt:master Aug 26, 2026
3 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants