Skip to content

Commit 0489e05

Browse files
committed
updated url check
1 parent afb03ab commit 0489e05

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/platforms/browser/WebPlatform.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,16 @@ export default class WebPlatform {
290290
}
291291
} else if (this._imageWorker) {
292292
// WPE-specific image parser.
293-
// image urls can be like "//example.com/image.png"
294-
if (typeof src !== 'string' || (src.indexOf('://') < 0 && !src.startsWith('//'))){
293+
if (typeof src !== 'string') {
295294
return cb("Invalid image URL");
296295
}
296+
297+
// URL can start with http://, https://, and //
298+
const separatorPos = src.indexOf('//');
299+
if (separatorPos !== 0 && separatorPos !== 5 && separatorPos !== 6) {
300+
return cb("Invalid image URL");
301+
}
302+
297303
const image = this._imageWorker.create(src);
298304
image.onError = function (err) {
299305
return cb("Image load error");

0 commit comments

Comments
 (0)