Fix redirect logic for ffprobe pre-flight check

This commit is contained in:
Calvin Montgomery 2020-01-11 11:24:20 -08:00
parent 842d0bb4be
commit c809b1994a
2 changed files with 11 additions and 2 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.67.0", "version": "3.67.1",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -84,7 +84,9 @@ function initFFLog() {
} }
function fixRedirectIfNeeded(urldata, redirect) { function fixRedirectIfNeeded(urldata, redirect) {
if (!/^https:/.test(redirect)) { let parsedRedirect = urlparse.parse(redirect);
if (parsedRedirect.host === null) {
// Relative path, munge it to absolute
redirect = urldata.protocol + "//" + urldata.host + redirect; redirect = urldata.protocol + "//" + urldata.host + redirect;
} }
@ -135,6 +137,13 @@ function testUrl(url, cb, params = { redirCount: 0, cookie: '' }) {
const { redirCount, cookie } = params; const { redirCount, cookie } = params;
var data = urlparse.parse(url); var data = urlparse.parse(url);
if (!/https:/.test(data.protocol)) { if (!/https:/.test(data.protocol)) {
if (redirCount > 0) {
// If the original URL redirected, the user is probably not aware
// that the link they entered (which was HTTPS) is redirecting to a
// non-HTTPS endpoint
return cb(`Unexpected redirect to a non-HTTPS link: ${url}`);
}
return cb("Only links starting with 'https://' are supported " + return cb("Only links starting with 'https://' are supported " +
"for raw audio/video support"); "for raw audio/video support");
} }