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:
This commit is contained in:
Guangcong Luo
2015-12-13 13:27:04 -05:00
parent 1bcc75e750
commit c33cfdfece

View File

@@ -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);