Bug 1962681 - r=Standard8 a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D250488
This commit is contained in:
James Teow
2025-05-27 16:29:06 +00:00
committed by dmeehan@mozilla.com
parent b6ec1ebbe2
commit f3267d9d24

View File

@@ -527,25 +527,12 @@ class SearchAdImpression {
return "";
}
// Avoid extracting or fixing up Javascript URLs.
if (href.startsWith("javascript")) {
let url = URL.parse(href, origin);
if (!url || (url.protocol !== "https:" && url.protocol !== "http:")) {
return "";
}
// Hrefs can be relative.
if (!href.startsWith("https://") && !href.startsWith("http://")) {
href = origin + href;
}
// Per Bug 376844, apostrophes in query params are escaped, and thus, are
// percent-encoded by the time they are observed in the network. Even
// though it's more comprehensive, we avoid using newURI because its more
// expensive and conversions should be the exception.
// e.g. /path'?q=Mozilla's -> /path'?q=Mozilla%27s
let arr = href.split("?");
if (arr.length == 2 && arr[1].includes("'")) {
href = arr[0] + "?" + arr[1].replaceAll("'", "%27");
}
return href;
return url.href;
}
/**