Skip to content

Commit 2228f81

Browse files
committed
block externally-hosted m3u files;
pointless security risk; made GHSA-9q4r-x2hj-jmvr much worse
1 parent 895880a commit 2228f81

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

copyparty/web/browser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6046,6 +6046,7 @@ var showfile = (function () {
60466046
m = /[?&](k=[^&#]+)/.exec(url);
60476047

60486048
url = url.split('?')[0] + (m ? '?' + m[1] : '');
6049+
assert_vp(url);
60496050
if (r.taildoc)
60506051
return r.tail(url, no_push);
60516052

@@ -7540,6 +7541,7 @@ function ev_load_m3u(e) {
75407541
return false;
75417542
}
75427543
function load_m3u(url) {
7544+
assert_vp(url);
75437545
var xhr = new XHR();
75447546
xhr.open('GET', url, true);
75457547
xhr.onload = render_m3u;

copyparty/web/util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,10 @@ if (!String.prototype.format)
383383
});
384384
};
385385

386+
var have_URL = false;
386387
try {
387388
new URL('/a/', 'https://a.com/');
389+
have_URL = true;
388390
}
389391
catch (ex) {
390392
console.log('ie11 shim URL()');
@@ -732,6 +734,16 @@ function makeSortable(table, cb) {
732734
}
733735

734736

737+
function assert_vp(path) {
738+
if (path.indexOf('//') + 1)
739+
throw 'nonlocal1: ' + path;
740+
741+
var o = window.location.origin;
742+
if (have_URL && (new URL(path, o)).origin != o)
743+
throw 'nonlocal2: ' + path;
744+
}
745+
746+
735747
function linksplit(rp, id) {
736748
var ret = [],
737749
apath = '/',

0 commit comments

Comments
 (0)