From 887a87d9ca8d575f3e71708086f44df96ac7cbc7 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 11 Sep 2022 12:20:01 -0400 Subject: [PATCH] Add support to report/filter SVG image elements Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2260 --- src/js/scriptlets/epicker.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/js/scriptlets/epicker.js b/src/js/scriptlets/epicker.js index 2a871ef76..c16f5b063 100644 --- a/src/js/scriptlets/epicker.js +++ b/src/js/scriptlets/epicker.js @@ -221,7 +221,8 @@ const backgroundImageURLFromElement = function(elem) { // https://github.com/gorhill/uBlock/issues/1725#issuecomment-226479197 // Limit returned string to 1024 characters. // Also, return only URLs which will be seen by an HTTP observer. - +// https://github.com/uBlockOrigin/uBlock-issues/issues/2260 +// Maybe get to the actual URL indirectly. const resourceURLsFromElement = function(elem) { const urls = []; const tagName = elem.localName; @@ -231,7 +232,10 @@ const resourceURLsFromElement = function(elem) { if ( url !== '' ) { urls.push(url); } return urls; } - const s = elem[prop]; + let s = elem[prop]; + if ( s instanceof SVGAnimatedString ) { + s = s.baseVal; + } if ( typeof s === 'string' && /^https?:\/\//.test(s) ) { urls.push(trimFragmentFromURL(s.slice(0, 1024))); } @@ -376,6 +380,7 @@ const netFilter1stSources = { 'embed': 'src', 'iframe': 'src', 'img': 'src', + 'image': 'href', 'object': 'data', 'source': 'src', 'video': 'src' @@ -671,12 +676,17 @@ const filterToDOMInterface = (( ) => { } // Lookup by tag names. + // https://github.com/uBlockOrigin/uBlock-issues/issues/2260 + // Maybe get to the actual URL indirectly. const elems = document.querySelectorAll( Object.keys(netFilter1stSources).join() ); for ( const elem of elems ) { const srcProp = netFilter1stSources[elem.localName]; - const src = elem[srcProp]; + let src = elem[srcProp]; + if ( src instanceof SVGAnimatedString ) { + src = src.baseVal; + } if ( typeof src === 'string' && reFilter.test(src) ||