Skip to content

Add support for parsing Link Header with variable whitespace - #7322

Merged
Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:link-header-whitespace
Jul 24, 2018
Merged

Add support for parsing Link Header with variable whitespace#7322
Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:link-header-whitespace

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Jul 20, 2018

Copy link
Copy Markdown
Member

add support for variable whitespace in link header

PR Summary

Thanks to the Chris Ruscio (@cruscio)'s analysis, it appears that the Link Header allows for any amount of whitespace or even no whitespace. The currently explicitly expect a single whitespace after the semicolon in the Link Header before the Rel property.

Fix is to change the regex to allow for variable or no whitespace and associated tests to handle these two cases. Changed GetLink helper to support passing in whitespace to use.

Fix #5667

PR Checklist

add support for variable whitespace in link header
fix codefactor issues
// we only support the URL in angle brackets and `rel`, other attributes are ignored
// user can still parse it themselves via the Headers property
string pattern = "<(?<url>.*?)>;\\srel=\"(?<rel>.*?)\"";
string pattern = "<(?<url>.*?)>;\\s*rel=\"(?<rel>.*?)\"";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not introduce any overlapping terms

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved, I misread the Regex

@markekraus Mark Kraus (markekraus) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@markekraus
Mark Kraus (markekraus) dismissed their stale review July 21, 2018 12:23

documentation needed

@markekraus Mark Kraus (markekraus) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

Mark Kraus (@markekraus) added documentation!

@iSazonov
Ilya (iSazonov) merged commit f5a7d79 into PowerShell:master Jul 24, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the link-header-whitespace branch July 24, 2018 16:28
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…ell#7322)

Fix is to change the regex to allow for variable or no whitespace and associated tests to handle these two cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants