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 match the specification in RFC 8288 section 3. Alternative to another outstanding PR that disables validation entirely.

Fixes: #46453
Refs: https://www.rfc-editor.org/rfc/rfc8288.html#section-3
Refs: #46464
  • Loading branch information
SRHerzog committed Feb 1, 2023
1 parent 8e42d8c commit 1dfd09c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/validators.js
Original file line number Diff line number Diff line change
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 All @@ -473,7 +473,7 @@ function validateLinkHeaderFormat(value, name) {
throw new ERR_INVALID_ARG_VALUE(
name,
value,
'must be an array or string of format "</styles.css>; rel=preload; as=style"'
`must be an array or string of format '</styles.css>; rel=preload; as="style"'`
);
}
}
Expand Down

0 comments on commit 1dfd09c

Please sign in to comment.