mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
#1735: remove spurious whitespaces from data URI description fields
This commit is contained in:
parent
63691a26ef
commit
6e81771783
@ -240,10 +240,25 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
// http://raymondhill.net/ublock/popup.html
|
// http://raymondhill.net/ublock/popup.html
|
||||||
var reGoodForWebRequestAPI = /^https?:\/\//;
|
var reGoodForWebRequestAPI = /^https?:\/\//;
|
||||||
|
|
||||||
|
// https://forums.lanik.us/viewtopic.php?f=62&t=32826
|
||||||
|
// Chromium-based browsers: sanitize target URL. I've seen
|
||||||
|
// data: URI-based with newline characters, possibly as a way of
|
||||||
|
// evading filters. There should be no whitespaces in a data: URI's
|
||||||
|
// standard fields.
|
||||||
|
var sanitizeURL = function(url) {
|
||||||
|
if ( url.startsWith('data:') === false ) { return url; }
|
||||||
|
var pos = url.indexOf(',');
|
||||||
|
if ( pos === -1 ) { return url; }
|
||||||
|
var s = url.slice(0, pos);
|
||||||
|
if ( s.search(/\s/) === -1 ) { return url; }
|
||||||
|
return s.replace(/\s+/, '') + url.slice(pos);
|
||||||
|
};
|
||||||
|
|
||||||
var onCreatedNavigationTarget = function(details) {
|
var onCreatedNavigationTarget = function(details) {
|
||||||
//console.debug('onCreatedNavigationTarget: popup candidate tab id %d = "%s"', details.tabId, details.url);
|
//console.debug('onCreatedNavigationTarget: popup candidate tab id %d = "%s"', details.tabId, details.url);
|
||||||
if ( reGoodForWebRequestAPI.test(details.url) === false ) {
|
if ( reGoodForWebRequestAPI.test(details.url) === false ) {
|
||||||
details.frameId = 0;
|
details.frameId = 0;
|
||||||
|
details.url = sanitizeURL(details.url);
|
||||||
onNavigationClient(details);
|
onNavigationClient(details);
|
||||||
}
|
}
|
||||||
if ( typeof vAPI.tabs.onPopupCreated === 'function' ) {
|
if ( typeof vAPI.tabs.onPopupCreated === 'function' ) {
|
||||||
@ -261,6 +276,7 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
if ( details.frameId !== 0 ) {
|
if ( details.frameId !== 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
details.url = sanitizeURL(details.url);
|
||||||
onNavigationClient(details);
|
onNavigationClient(details);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -269,6 +285,9 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var onUpdated = function(tabId, changeInfo, tab) {
|
var onUpdated = function(tabId, changeInfo, tab) {
|
||||||
|
if ( changeInfo.url ) {
|
||||||
|
changeInfo.url = sanitizeURL(changeInfo.url);
|
||||||
|
}
|
||||||
onUpdatedClient(tabId, changeInfo, tab);
|
onUpdatedClient(tabId, changeInfo, tab);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user