Skip to content

Commit 2880238

Browse files
doublevkayKhang. Võ VĩLinusU
authored
fix: ReDoS referrer (#1611)
* fix ReDoS referrer * Update src/utils/referrer.js Eliminate regex and use string matcher Co-authored-by: Linus Unnebäck <[email protected]> Co-authored-by: Khang. Võ Vĩ <[email protected]> Co-authored-by: Linus Unnebäck <[email protected]>
1 parent e87b093 commit 2880238

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/utils/referrer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function isOriginPotentiallyTrustworthy(url) {
119119
// 5. If origin's host component is "localhost" or falls within ".localhost", and the user agent conforms to the name resolution rules in [let-localhost-be-localhost], return "Potentially Trustworthy".
120120
// We are returning FALSE here because we cannot ensure conformance to
121121
// let-localhost-be-loalhost (https://tools.ietf.org/html/draft-west-let-localhost-be-localhost)
122-
if (/^(.+\.)*localhost$/.test(url.host)) {
122+
if (url.host === 'localhost' || url.host.endsWith('.localhost')) {
123123
return false;
124124
}
125125

0 commit comments

Comments
 (0)