Skip to content

Commit 4dc4468

Browse files
n0samuHerschel
authored andcommitted
extension: Check more thoroughly for SWF filenames and MIME types
1 parent c83ae11 commit 4dc4468

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

web/packages/extension/src/background.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as utils from "./utils";
2+
import { isSwfFilename, isSwfMimeType } from "ruffle-core";
23

34
function isSwf(
45
details:
@@ -23,12 +24,10 @@ function isSwf(
2324

2425
// Some sites (e.g. swfchan.net) might (wrongly?) send octet-stream, so check file extension too.
2526
if (mime.endsWith("octet-stream")) {
26-
const url = new URL(details.url);
27-
const extension = url.pathname.substring(url.pathname.lastIndexOf("."));
28-
return extension.toLowerCase() === ".swf";
27+
return isSwfFilename(details.url);
28+
} else {
29+
return isSwfMimeType(mime);
2930
}
30-
31-
return mime === "application/x-shockwave-flash";
3231
}
3332

3433
function onHeadersReceived(

0 commit comments

Comments
 (0)