From c33cfdfecef8b0f36cf2db2743283ecaf4c58006 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sun, 13 Dec 2015 13:27:04 -0500 Subject: [PATCH] Rewrite protocol-relative images to http: if necessary This makes protocol-relative images in sanitized HTML work in testclient, by manually setting the protocol to http: --- js/battledata.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/battledata.js b/js/battledata.js index 145ea6a2f..24c440699 100644 --- a/js/battledata.js +++ b/js/battledata.js @@ -645,6 +645,11 @@ var Tools = { srcIdx = i; dataUri = attribs[i + 1]; } + if (attribs[i] === 'src' && attribs[i + 1].substr(0, 2) === '//') { + if (location.protocol !== 'http:' && location.protocol !== 'https:') { + attribs[i + 1] = 'http:' + attribs[i + 1]; + } + } } } attribs = html.sanitizeAttribs(tagName, attribs, uriRewriter);