Skip to content
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

Link header parsing breaks for multiple links with at least one containing unquoted values #1899

Closed
kdefives opened this issue Feb 2, 2023 · 1 comment
Assignees
Labels
in: core Core parts of the project type: bug
Milestone

Comments

@kdefives
Copy link
Contributor

kdefives commented Feb 2, 2023

Hello,

Seems the REGEX used inside Links parse(@ Nullable String source); function is not compliant with a part of RFC8288 Section 3 : https://www.rfc-editor.org/rfc/rfc8288.html#section-3
Related to the usage of "rel" attribute, seems it could be use in both following way (quoted and not quoted value):

  • rel=boo
  • rel="boo"

Extract from RFC8288:

Link Serialisation in HTTP Headers

The Link header field provides a means for serialising one or more
links into HTTP headers.

The ABNF for the field value is:

Link       = #link-value
link-value = "<" URI-Reference ">" *( OWS ";" OWS link-param )
link-param = token BWS [ "=" BWS ( token / quoted-string ) ]

Note that any link-param can be generated with values using either
the token or the quoted-string syntax; therefore, recipients MUST be
able to parse both forms. In other words, the following parameters
are equivalent:

x=y
x="y"

The function do not parse the header correctly if we got a rel value without quotes.

I did a fork with a unit test which is failing currently, but if what i am saying is right, it should pass after the fix: #1898

I know a RFC can be misinterpreted so feel free to tell me if i am wrong and if "rel" value MUST be quoted all the time.

Regards,

odrotbohm added a commit that referenced this issue Feb 15, 2023
…bute values.

Fixed the regular expression to parse link header values to properly consider the comma to end an unquoted attribute value, too. Couple of additional unit tests, too.
@odrotbohm odrotbohm changed the title Support unquoted rel value in Links Header - RFC8288 Section 3 Link header parsing breaks for multiple links with at least one containing unquoted values Feb 15, 2023
@odrotbohm odrotbohm self-assigned this Feb 15, 2023
@odrotbohm odrotbohm added type: bug in: core Core parts of the project labels Feb 15, 2023
@odrotbohm odrotbohm added this to the 2.1.0-M1 milestone Feb 15, 2023
@odrotbohm
Copy link
Member

Good catch! It's not been unquoted values per se, but the combination of multiple links and the regex not properly detecting a value ending at a comma. I applied your PR and expanded the test cases in the actual fix. Backported to 2.0.x and 1.5.x, both due to ship releases this Friday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core parts of the project type: bug
Projects
None yet
Development

No branches or pull requests

2 participants