fix: allow "#", "?", and "?#" as valid URI references per RFC 3986#910
Conversation
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>
|
🎉 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! 💪🚀 |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
💖 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. 🌱✨ |
Summary
RelativeReferenceValidatorthat rejected#,?, and?#as invalid relative references#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-referencefor link props in SDC (Single Directory Components), andhref="#"is common in HTML.Fixes #909