Skip to content

fix: allow "#", "?", and "?#" as valid URI references per RFC 3986#910

Merged
DannyvdSluijs merged 2 commits into
jsonrainbow:mainfrom
penyaskito:fix/909-relative-reference-fragment-query
May 27, 2026
Merged

fix: allow "#", "?", and "?#" as valid URI references per RFC 3986#910
DannyvdSluijs merged 2 commits into
jsonrainbow:mainfrom
penyaskito:fix/909-relative-reference-fragment-query

Conversation

@penyaskito

Copy link
Copy Markdown
Contributor

Summary

  • Removes two incorrect checks in RelativeReferenceValidator that rejected #, ?, and ?# as invalid relative references
  • Moves these values to the valid test data provider and adds additional valid cases (#section, ?query#fragment)

Per RFC 3986 Section 4.2, these are valid relative-references composed of path-empty + fragment and/or query. The grammar allows zero-length paths, queries, and fragments.

This is a real-world issue: Drupal's Canvas component builder and Byte theme use format: uri-reference for link props in SDC (Single Directory Components), and href="#" is common in HTML.

Fixes #909

These are valid relative-references: path-empty + fragment/query.
The RFC grammar explicitly allows zero-length paths, queries, and
fragments via the "*" (zero-or-more) quantifier.

Fixes jsonrainbow#909

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎉 You're making a difference! We appreciate your effort and dedication. A reviewer will check it out soon, but in the meantime, give yourself a pat on the back. Keep up the great work! 💪🚀

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes format: uri-reference validation to align with RFC 3986 relative-reference grammar by allowing empty-path references that contain only a query and/or fragment (e.g., #, ?, ?#). This improves real-world compatibility for common HTML-style link values.

Changes:

  • Removed overly-restrictive checks in RelativeReferenceValidator::isValid() that rejected #, ?, and ?#.
  • Updated unit tests to classify these as valid and added additional valid examples (#section, ?query#fragment).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/JsonSchema/Tool/Validator/RelativeReferenceValidator.php Removes the special-case rejections so RFC 3986-valid relative references like #, ?, and ?# validate successfully.
tests/Tool/Validator/RelativeReferenceValidatorTest.php Moves #/? into valid cases and adds additional valid coverage around fragments and query+fragment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Tool/Validator/RelativeReferenceValidatorTest.php
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@DannyvdSluijs DannyvdSluijs merged commit e444d9d into jsonrainbow:main May 27, 2026
18 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

💖 Welcome @penyaskito as first-time contributor! Your efforts matter, and we’re so grateful for your contribution. Open source thrives because of people like you. Keep going, keep learning, and know that your work is truly valued. 🌱✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RelativeReferenceValidator incorrectly rejects "#", "?", and "?#" as invalid URI references

3 participants