Skip to content

Commit

Permalink
http: fix validation of "Link" header
Browse files Browse the repository at this point in the history
Updated regex for "Link" header validation to better match the
specification in RFC 8288 section 3. Does not check for valid URI
format but handles the rest of the header more permissively than
before. Alternative to another outstanding PR that disables validation
entirely.

Fixes: nodejs#46453
Refs: https://www.rfc-editor.org/rfc/rfc8288.html#section-3
Refs: nodejs#46464
  • Loading branch information
SRHerzog committed Feb 17, 2023
1 parent 7796692 commit 9947fd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/validators.js
Expand Up @@ -459,7 +459,7 @@ function validateUnion(value, name, union) {
}
}

const linkValueRegExp = /^(?:<[^>]*>;)\s*(?:rel=(")?[^;"]*\1;?)\s*(?:(?:as|anchor|title|crossorigin|disabled|fetchpriority|rel|referrerpolicy)=(")?[^;"]*\2)?$/;
const linkValueRegExp = /^(?:<[^>]*>)(?:\s*;\s*[^;"]+(?:=(")?[^;"]*\1)?)*$/;

/**
* @param {any} value
Expand Down

0 comments on commit 9947fd9

Please sign in to comment.