Skip to content

Commit 889e1dc

Browse files
committed
Prevent data: URIs from messing with srcset parsing (thanks fatboy for reporting).
1 parent 8243c65 commit 889e1dc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/content/eventsHook.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@ if (location.protocol == "file:") {
142142

143143
const srcUrls = srcset => {
144144
const urls = [];
145+
// remove data: URLs whose comma may mess with the splitting
146+
srcset = srcset.replace(/(?:^|,)\s*data:[^\s,]*,[^,]*/g, '');
145147
for (const s of srcset.split(/\s*,s*/)) {
146-
try {
147-
urls.push(new URL(s.trim().split(/\s+/)[0], document.baseURI))
148-
} catch (e) {
148+
if (s) {
149+
try {
150+
urls.push(new URL(s.trim().split(/\s+/)[0], document.baseURI))
151+
} catch (e) {
152+
}
149153
}
150154
}
151155
return urls;

0 commit comments

Comments
 (0)