Skip to content

Link Header pagination fails when there's no space between ';' and 'rel' #5667

Closed

Description

@cruscio

If links in a Link header do not contain a space between ; and rel then invoke-webrequest fails to populate the RelationLink property

<http://localhost:8080/PowerShell?test=linkheader&maxlinks=5&linknumber=1>; rel="self"
<http://localhost:8080/PowerShell?test=linkheader&maxlinks=5&linknumber=1>;rel="self"

Not having a space is valid (more appropriate, even) per the specification: https://tools.ietf.org/html/rfc5988 page 6

For reference

#5265 [Feature] Add Multiple Link Header Support

Code

Test

It "Validate Invoke-WebRequest returns valid RelationLink property with absolute uris if Link Header is present" {

I think the appropriate fix would be to change \\s to \\s* to allow for 0 or more whitespace rather than requiring a single whitespace

Activity

  1. markekraus commented on Dec 11, 2017

    @markekraus
    Contributor

    Hmm rfc has

    link-value     = "<" URI-Reference ">" *( ";" link-param )
    

    The * is interesting. I couldn't find whether they mean "zero or more" spaces or "one or more" spaces. I'm not sure it really matters. The current regex definitely doesn't cover either. 😃

    I'm ok with the proposed change.

  2. added
    Issue-Bug
    on Dec 11, 2017
  3. cruscio commented on Dec 11, 2017

    @cruscio
    Author

    whether they mean "zero or more" spaces or "one or more" spaces

    At the risk of being pedantic, the specification doesn't explicitly allow any whitespace there. The *() indicates one or more instances of ;link-param can follow <URI-Reference> - with no whitespace after the > or bfore the ; .

    That said, RFC5988 follows RFC2616 ABNF notation, which implicitly allows for linear white space (LWS) between any two adjacent tokens or quoted-strings, and between adjacent words and separators.

    https://tools.ietf.org/html/rfc2616#section-2.2

    LWS            = [CRLF] 1*( SP | HT )
    SP             = <US-ASCII SP, space (32)>
    HT             = <US-ASCII HT, horizontal-tab (9)>
    

    https://tools.ietf.org/html/rfc2616#section-2.1

    implied *LWS
          The grammar described by this specification is word-based. Except
          where noted otherwise, linear white space (LWS) can be included
          between any two adjacent words (token or quoted-string), and
          between adjacent words and separators, without changing the
          interpretation of a field. At least one delimiter (LWS and/or
    
          separators) MUST exist between any two tokens (for the definition
          of "token" below), since they would otherwise be interpreted as a
          single token.
    

    In link-value = "<" URI-Reference ">" *( ";" link-param ), ";" is a quoted string and link-param is a token, so the space is implicitly allowed between them, but not required.

    Anyway, I think we're on the same page; just wanted to clarify the interpretation of the RFC

  4. markekraus commented on Dec 11, 2017

    @markekraus
    Contributor

    Ugh.. one of these days I will learn how to properly translate RFC's into actual things... Today is not that day. Thanks for explaining.

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

Metadata

Metadata

Labels

Issue-BugResolution-FixedWG-Cmdlets

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions