-
Notifications
You must be signed in to change notification settings - Fork 217
Update 'qualifiers' rule in core spec #382 #398
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 1 commit
1c1fb31
b621d65
17685b2
654e1b9
9d849b9
ccf07c5
2a13760
42e7ec0
9a7089b
898c64b
3d2a128
a990290
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||
| Package URL specification v1.0.X | ||||||||||
| ================================ | ||||||||||
| Package URL specification v1.0.X (from qualifiers PR) | ||||||||||
| ===================================================== | ||||||||||
|
|
||||||||||
| The Package URL core specification defines a versioned and formalized format, | ||||||||||
| syntax, and rules used to represent and validate ``purl``. | ||||||||||
|
|
@@ -136,6 +136,8 @@ The rules for each component are: | |||||||||
| - The ``type`` MUST start with an ASCII letter. | ||||||||||
| - The ``type`` MUST NOT be percent-encoded. | ||||||||||
| - The ``type`` is case insensitive. The canonical form is lowercase. | ||||||||||
| - ``purl`` parsers MUST return an error when the ``type`` contains a prohibited | ||||||||||
johnmhoran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| character. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| - **namespace**: | ||||||||||
|
|
@@ -176,25 +178,106 @@ The rules for each component are: | |||||||||
|
|
||||||||||
| - **qualifiers**: | ||||||||||
|
|
||||||||||
| - The ``qualifiers`` string is prefixed by a '?' separator when not empty | ||||||||||
| - This '?' is not part of the ``qualifiers`` | ||||||||||
| - This is a query string composed of zero or more ``key=value`` pairs each | ||||||||||
| separated by a '&' ampersand. A ``key`` and ``value`` are separated by the equal | ||||||||||
| '=' character | ||||||||||
| - These '&' are not part of the ``key=value`` pairs. | ||||||||||
| - ``key`` must be unique within the keys of the ``qualifiers`` string | ||||||||||
| - ``value`` cannot be an empty string: a ``key=value`` pair with an empty ``value`` | ||||||||||
| is the same as no key/value at all for this key | ||||||||||
| - For each pair of ``key`` = ``value``: | ||||||||||
|
|
||||||||||
| - The ``key`` must be composed only of ASCII letters and numbers, '.', '-' and | ||||||||||
| '_' (period, dash and underscore) | ||||||||||
| - A ``key`` cannot start with a number | ||||||||||
| - A ``key`` must NOT be percent-encoded | ||||||||||
| - A ``key`` is case insensitive. The canonical form is lowercase | ||||||||||
| - A ``key`` cannot contain spaces | ||||||||||
| - A ``value`` must be a percent-encoded string | ||||||||||
| - The '=' separator is neither part of the ``key`` nor of the ``value`` | ||||||||||
| - The ``qualifiers`` component MUST be prefixed by a '?' separator when not empty. | ||||||||||
| - The '?' separator is not part of the ``qualifiers`` component. | ||||||||||
| - The ``qualifiers`` component is a query string composed of one or more ``key=value`` | ||||||||||
| pairs, each of which is separated by an ampersand '&'. A ``key`` and ``value`` | ||||||||||
pombredanne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| are separated by the equal '=' character. | ||||||||||
johnmhoran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| - The '&' separator is not part of the ``key`` or the ``value``. | ||||||||||
pombredanne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| - The '=' separator is not part of the ``key`` or the ``value``. | ||||||||||
pombredanne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| - The ``key`` MUST be unique among the keys of the ``qualifiers`` string. | ||||||||||
pombredanne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| - The ``value`` MUST NOT be an empty string: a ``key=value`` pair with an empty ``value`` | ||||||||||
johnmhoran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| is the same as no ``key=value`` pair at all for this ``key``. | ||||||||||
|
||||||||||
| is the same as no ``key=value`` pair at all for this ``key``. | |
| is the same as if no ``key=value`` pair exists for this ``key``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good clarification -- done.
johnmhoran marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
keyMUST NOT be percent-encoded.
I think this is wrong, and against other existing spec
purl-spec/PURL-SPECIFICATION.rst
Lines 245 to 248 in 8040ff0
| It is OK to percent-encode ``purl`` components otherwise except for the ``type``. | |
| Parsers and builders must always percent-decode and percent-encode ``purl`` | |
| components and component segments as explained in the "How to parse" and "How to | |
| build" sections. |
I think a key can be percent-encoded. and at some points, it must be percent encoded.
Otherwise, if percent-encoding MUST NOT happen, then i could not choose certain keys.
examples: foo&bar[]=bazz -> foo%26bar%5B%5D -- at least the & MUST be percent-encoded.
I might be wrong, please help me understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foo&bar[]=bazz is not a valid key according to the preceding rules. The allowed characters shouldn't require percent encoding but I don't see why the spec would forbid percent encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current spec already spells this out clearly, so this is not changing anything:
- A ``key`` must NOT be percent-encoded
Now since the % sign is not allowed in a key, technically, this is implied already and we could remove this sentence entirely. I like this to be explicit though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the comments thus far ^, I'm keeping as is unless/until I hear otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 - keep as you have it right now
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing and self contradictory. "The value MUST be composed only of the following characters", but then the following text defines a set containing all characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @matt-phylum -- I don't think it's confusing but in any event the revised update will be simplified and clarified.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous item lists characters that should not be encoded (MUST NOT for canonical PURLs), but this item lists some characters that MUST be encoded and some characters that should not be encoded together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will look forward to your comments on the revised update once I've pushed it.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This contradicts preexisting rules:
purl-spec/PURL-SPECIFICATION.rst
Lines 238 to 241 in 8040ff0
| - the '@' ``version`` separator must be encoded as ``%40`` elsewhere | |
| - the '?' ``qualifiers`` separator must be encoded as ``%3F`` elsewhere | |
| - the '=' ``qualifiers`` key/value separator must NOT be encoded | |
| - the '#' ``subpath`` separator must be encoded as ``%23`` elsewhere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be clarified in the update.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change to the PURL canonicalization rules and will cause problems for anyone who is using canonicalized PURLs as keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be clarified in the update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matt-phylum As you'll see elsewhere in these comments, I've deleted what was intended as a simple placeholder rule hoping people would provide language they wanted. Failing that, it's been deleted.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way too complicated to be one bullet point in the qualifiers section.
The encoding rules are:
- The ASCII control characters 0 through 31 and 127 and any non-ASCII character greater than or equal to 128 MUST always be encoded in any component of a PURL.
%which MUST always be encoded in any percent encoded string.- The additional characters
"<>SHOULD always be encoded in any component of a PURL. - The additional characters
#@?MUST be encoded for qualifier values.
Plus should also be encoded to avoid interoperability problems: #261
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be clarified in the update.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect and incompatible with the preexisting spec.
In the unescaped form, no characters are prohibited, so you could have a valid PURL pkg:generic/name?key=%00 and the parser must handle this (or maybe it returns an error because it's string type can't represent null characters).
In the escaped form, some characters are escaped to avoid problems unrelated to the URL. http://example.com/?key=a "value" and http://example.com/?key=a%20%22value%22 are the same, but if you write Go to http://example.com/?key=a "value" or <a href="http://example.com/?key=a "value""> it doesn't work. At least I'm pretty sure why it's done. These characters have no meaning to the URL or PURL parsers so whether they are escaped or not doesn't make a difference to the parsing result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that inclusion of a prohibited character could only be "normalized" by removing/discarding such a character, which does not sound to me like mere normalization. I look to feedback from @pombredanne and others on this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm misunderstanding. There are no characters that are prohibited in the unencoded form of a qualifier value. In the encoded form, there are characters that are listed above as requiring escaping that don't actually require escaping in order for the PURL to be parsed successfully. If it can be unambiguously parsed and the result can be formatted into a PURL with the same meaning, I don't think that should be a "MUST return an error" condition. The characters do not need to be removed or discarded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. I must admit that I don't yet have a good understanding of when a violation of the spec should be normalized (allowing the parsing process to continue) vs. treating a spec violation as invalid (i.e., "is_invalid": true, raising an error/exception and thus halting the parsing process).
I'd be interested in reading any authorities/resources you could point me to on this important topic -- and in all events I'll happily defer to whatever approach you, @pombredanne, @jkowalleck, @mprpic and others in the community ultimately agree to.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ Scheme | |||||
|
|
||||||
| **QUESTION**: Can the ``scheme`` component be followed by a colon and two slashes, like a URI? | ||||||
|
|
||||||
| No. Since a ``purl`` never contains a URL Authority, its ``scheme`` should not be suffixed with double slash as in 'pkg://' and should use 'pkg:' instead. Otherwise this would be an invalid URI per RFC 3986 at https://tools.ietf.org/html/rfc3986#section-3.3:: | ||||||
| **ANSWER**: No. Since a ``purl`` never contains a URL Authority, its ``scheme`` should not be suffixed with double slash as in 'pkg://' and should use 'pkg:' instead. Otherwise this would be an invalid URI per RFC 3986 at https://tools.ietf.org/html/rfc3986#section-3.3:: | ||||||
|
|
||||||
| If a URI does not contain an authority component, then the path | ||||||
| cannot begin with two slash characters ("//"). | ||||||
|
|
@@ -24,9 +24,10 @@ For example, although these two purls are strictly equivalent, the first is in c | |||||
|
|
||||||
| pkg://gem/ruby-advisory-db-check@0.12.4 | ||||||
|
|
||||||
|
|
||||||
| **QUESTION**: Is the colon between ``scheme`` and ``type`` encoded? Can it be encoded? If yes, how? | ||||||
|
|
||||||
| The "Rules for each ``purl`` component" section provides that "[t]he ``scheme`` MUST be followed by an unencoded colon ':'. | ||||||
| **ANSWER**: The "Rules for each ``purl`` component" section provides that "[t]he ``scheme`` MUST be followed by an unencoded colon ':'. | ||||||
|
||||||
| **ANSWER**: The "Rules for each ``purl`` component" section provides that "[t]he ``scheme`` MUST be followed by an unencoded colon ':'. | |
| **ANSWER**: The "Rules for each ``purl`` component" section provides that the ``scheme`` MUST be followed by an unencoded colon ':'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point -- fixed.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnmhoran Can we refine this with the new wording? and remove the the weird square brackets in [t]he?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pombredanne I've fixed the use of square brackets (thanks for catching that) and will commit and push these updates. I'm not sure what you are referring to by "the new wording" aside from the square brackets -- please clarify as needed once the revised faq.rst has been pushed.
Uh oh!
There was an error while loading. Please reload this page.