-
-
Notifications
You must be signed in to change notification settings - Fork 345
further specify the format of iri-references throughout #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ | |
"type": ["object", "boolean"], | ||
"properties": { | ||
"$id": { | ||
"$ref": "#/$defs/iriReferenceString", | ||
"type": "string", | ||
"format": "iri-reference", | ||
"$comment": "Non-empty fragments not allowed.", | ||
"pattern": "^[^#]*#?$" | ||
}, | ||
"$schema": { "$ref": "#/$defs/iriString" }, | ||
"$ref": { "$ref": "#/$defs/iriReferenceString" }, | ||
"$ref": { "$ref": "#/$defs/iriReferenceToSchemaString" }, | ||
"$anchor": { "$ref": "#/$defs/anchorString" }, | ||
"$dynamicRef": { "$ref": "#/$defs/iriReferenceString" }, | ||
"$dynamicRef": { "$ref": "#/$defs/iriReferenceToSchemaString" }, | ||
"$dynamicAnchor": { "$ref": "#/$defs/anchorString" }, | ||
"$vocabulary": { | ||
"type": "object", | ||
|
@@ -43,9 +44,11 @@ | |
"type": "string", | ||
"format": "iri" | ||
}, | ||
"iriReferenceString": { | ||
"iriReferenceToSchemaString": { | ||
"type": "string", | ||
"format": "iri-reference" | ||
"format": "iri-reference", | ||
"$comment": "any fragment must be empty, or match anchor or json-pointer syntax", | ||
"pattern": "^[^#]*(#([A-Za-z_][-A-Za-z0-9.:_]*|/([^~]|~[01])*))?$" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
"pattern": "^[^#]*(#([A-Za-z_][-A-Za-z0-9.:_]*|/([^~]|~[01])*))?$"
"pattern": "^[^#]*(#([A-Za-z_][-A-Za-z0-9.:_]*|(/([^~/]|~[01])*)*))?$"
The second half of the fragment match, for JSON Pointer, won't match the empty pointer ( This is still incomplete though. Fragments may contain %xx encoded characters. In a pointer their use may be necessary, but in either a pointer or anchor they are expected to be treated like the characters they represent, even when those characters don't actually need to be %-encoded.
Suggested change
"pattern": "^[^#]*(#([A-Za-z_][-A-Za-z0-9.:_]*|/([^~]|~[01])*))?$"
"pattern": "^[^#]*(#(([A-Za-z_]|%[A-Fa-f0-9]{2})([-A-Za-z0-9.:_]|%[A-Fa-f0-9]{2})*|((/|%2[fF])([^~/%]|~[01]|%[A-Fa-f0-9]{2})*)*))?$"
Not too pretty, but I think it allows anything that's valid. It won't reject some invalid anchors or pointers if they're %-encoded - it would be possible to express the same character ranges as allowed combinations of %-encoded digits, but I'm not masochistic enough to do it. I'm a little uncertain describing a uri fragment with a regex isn't more trouble than it's worth. |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ | |
}, | ||
"absoluteKeywordLocation": { | ||
"type": "string", | ||
"format": "uri" | ||
"format": "iri", | ||
"$comment": "any fragment must be non-empty, and use json-pointer syntax", | ||
"pattern": "^[^#]*(#(/([^~]|~[01])*)*)?$" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment says must be non-empty, but this does allow an empty fragment.
Suggested change
"pattern": "^[^#]*(#(/([^~]|~[01])*)*)?$"
"pattern": "^[^#]*(#(/([^~/]|~[01])*)+)?$"
The change to + requires a non-empty pointer; disallowing the / from the reference-token character range is better consistent with its spec's ABNF (and iriReferenceToSchemaString above), though it doesn't ultimately change what the regex matches. And of course %-encoding needs fixing here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I think we need to allow empty fragments, so it's the comment that is wrong here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @karenetheridge Agreed, you need to be able to represent the root with a JSON Pointer fragment, which would be an empty fragment. |
||
}, | ||
"instanceLocation": { | ||
"type": "string", | ||
|