A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/gorhill/uBlock/commit/2e4525fe3c509a636fc67776cd728819f54a7de6 below:

Add new static network filter option: `urltransform` · gorhill/uBlock@2e4525f · GitHub

File tree Expand file treeCollapse file tree 14 files changed

+110

-31

lines changed

Filter options

Expand file treeCollapse file tree 14 files changed

+110

-31

lines changed Original file line number Diff line number Diff line change

@@ -88,7 +88,7 @@ export function compile(details) {

88 88

const scriptletToken = details.args[0];

89 89

const resourceEntry = resourceDetails.get(scriptletToken);

90 90

if ( resourceEntry === undefined ) { return; }

91 -

if ( resourceEntry.requiresTrust && details.isTrusted !== true ) {

91 +

if ( resourceEntry.requiresTrust && details.trustedSource !== true ) {

92 92

console.log(`Rejecting ${scriptletToken}: source is not trusted`);

93 93

return;

94 94

}

Original file line number Diff line number Diff line change

@@ -48,6 +48,7 @@ const cmEditor = new CodeMirror(qs$('#userFilters'), {

48 48

styleActiveLine: {

49 49

nonEmpty: true,

50 50

},

51 +

trustedSource: true,

51 52

});

52 53 53 54

uBlockDashboard.patchCodeMirrorEditor(cmEditor);

Original file line number Diff line number Diff line change

@@ -82,6 +82,7 @@ import './codemirror/ubo-static-filtering.js';

82 82

what : 'getAssetContent',

83 83

url: assetKey,

84 84

});

85 +

cmEditor.setOption('trustedSource', details.trustedSource === true);

85 86

cmEditor.setValue(details && details.content || '');

86 87 87 88

if ( subscribeElem !== null ) {

Original file line number Diff line number Diff line change

@@ -181,7 +181,8 @@ const loadBenchmarkDataset = (( ) => {

181 181

if ( r === 1 ) { blockCount += 1; }

182 182

else if ( r === 2 ) { allowCount += 1; }

183 183

if ( r !== 1 ) {

184 -

if ( staticNetFilteringEngine.hasQuery(fctxt) ) {

184 +

staticNetFilteringEngine.transformRequest(fctxt);

185 +

if ( fctxt.redirectURL !== undefined && staticNetFilteringEngine.hasQuery(fctxt) ) {

185 186

staticNetFilteringEngine.filterQuery(fctxt, 'removeparam');

186 187

}

187 188

if ( fctxt.type === 'main_frame' || fctxt.type === 'sub_frame' ) {

Original file line number Diff line number Diff line change

@@ -37,12 +37,21 @@ const preparseDirectiveHints = [];

37 37

const originHints = [];

38 38

let hintHelperRegistered = false;

39 39 40 +

/******************************************************************************/

41 + 42 +

let trustedSource = false;

43 + 44 +

CodeMirror.defineOption('trustedSource', false, (cm, state) => {

45 +

trustedSource = state;

46 +

self.dispatchEvent(new Event('trustedSource'));

47 +

});

40 48 41 49

/******************************************************************************/

42 50 43 51

CodeMirror.defineMode('ubo-static-filtering', function() {

44 52

const astParser = new sfp.AstFilterParser({

45 53

interactive: true,

54 +

trustedSource,

46 55

nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),

47 56

});

48 57

const astWalker = astParser.getWalker();

@@ -205,7 +214,11 @@ CodeMirror.defineMode('ubo-static-filtering', function() {

205 214

return '+';

206 215

};

207 216 208 -

return {

217 +

self.addEventListener('trustedSource', ( ) => {

218 +

astParser.options.trustedSource = trustedSource;

219 +

});

220 + 221 +

return {

209 222

lineComment: '!',

210 223

token: function(stream) {

211 224

if ( stream.sol() ) {

@@ -977,6 +990,10 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {

977 990

}

978 991

};

979 992 993 +

self.addEventListener('trustedSource', ( ) => {

994 +

astParser.options.trustedSource = trustedSource;

995 +

});

996 + 980 997

CodeMirror.defineInitHook(cm => {

981 998

cm.on('changes', onChanges);

982 999

cm.on('beforeChange', onBeforeChanges);

Original file line number Diff line number Diff line change

@@ -108,6 +108,7 @@ const onMessage = function(request, sender, callback) {

108 108

dontCache: true,

109 109

needSourceURL: true,

110 110

}).then(result => {

111 +

result.trustedSource = µb.isTrustedList(result.assetKey);

111 112

callback(result);

112 113

});

113 114

return;

Original file line number Diff line number Diff line change

@@ -860,7 +860,7 @@ const PageStore = class {

860 860

if ( (fctxt.itype & fctxt.INLINE_ANY) === 0 ) {

861 861

if ( result === 1 ) {

862 862

this.redirectBlockedRequest(fctxt);

863 -

} else if ( snfe.hasQuery(fctxt) ) {

863 +

} else {

864 864

this.redirectNonBlockedRequest(fctxt);

865 865

}

866 866

}

@@ -922,25 +922,31 @@ const PageStore = class {

922 922

}

923 923 924 924

redirectBlockedRequest(fctxt) {

925 -

const directives = staticNetFilteringEngine.redirectRequest(

926 -

redirectEngine,

927 -

fctxt

928 -

);

925 +

const directives = staticNetFilteringEngine.redirectRequest(redirectEngine, fctxt);

929 926

if ( directives === undefined ) { return; }

930 927

if ( logger.enabled !== true ) { return; }

931 928

fctxt.pushFilters(directives.map(a => a.logData()));

932 929

if ( fctxt.redirectURL === undefined ) { return; }

933 930

fctxt.pushFilter({

934 931

source: 'redirect',

935 -

raw: redirectEngine.resourceNameRegister

932 +

raw: directives[directives.length-1].value

936 933

});

937 934

}

938 935 939 936

redirectNonBlockedRequest(fctxt) {

940 -

const directives = staticNetFilteringEngine.filterQuery(fctxt);

941 -

if ( directives === undefined ) { return; }

937 +

const transformDirectives = staticNetFilteringEngine.transformRequest(fctxt);

938 +

const pruneDirectives = fctxt.redirectURL === undefined &&

939 +

staticNetFilteringEngine.hasQuery(fctxt) &&

940 +

staticNetFilteringEngine.filterQuery(fctxt) ||

941 +

undefined;

942 +

if ( transformDirectives === undefined && pruneDirectives === undefined ) { return; }

942 943

if ( logger.enabled !== true ) { return; }

943 -

fctxt.pushFilters(directives.map(a => a.logData()));

944 +

if ( transformDirectives !== undefined ) {

945 +

fctxt.pushFilters(transformDirectives.map(a => a.logData()));

946 +

}

947 +

if ( pruneDirectives !== undefined ) {

948 +

fctxt.pushFilters(pruneDirectives.map(a => a.logData()));

949 +

}

944 950

if ( fctxt.redirectURL === undefined ) { return; }

945 951

fctxt.pushFilter({

946 952

source: 'redirect',

Original file line number Diff line number Diff line change

@@ -167,7 +167,6 @@ class RedirectEngine {

167 167

this.resources = new Map();

168 168

this.reset();

169 169

this.modifyTime = Date.now();

170 -

this.resourceNameRegister = '';

171 170

}

172 171 173 172

reset() {

@@ -183,7 +182,6 @@ class RedirectEngine {

183 182

) {

184 183

const entry = this.resources.get(this.aliases.get(token) || token);

185 184

if ( entry === undefined ) { return; }

186 -

this.resourceNameRegister = token;

187 185

return entry.toURL(fctxt, asDataURI);

188 186

}

189 187 Original file line number Diff line number Diff line change

@@ -131,6 +131,7 @@ const fromNetFilter = async function(rawFilter) {

131 131

const writer = new CompiledListWriter();

132 132

const parser = new sfp.AstFilterParser({

133 133

expertMode: true,

134 +

trustedSource: true,

134 135

maxTokenLength: staticNetFilteringEngine.MAX_TOKEN_LENGTH,

135 136

nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),

136 137

});

@@ -169,6 +170,7 @@ const fromExtendedFilter = async function(details) {

169 170 170 171

const parser = new sfp.AstFilterParser({

171 172

expertMode: true,

173 +

trustedSource: true,

172 174

nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),

173 175

});

174 176

parser.parse(details.rawFilter);

Original file line number Diff line number Diff line change

@@ -306,7 +306,7 @@ scriptletFilteringEngine.compile = function(parser, writer) {

306 306 307 307

// Only exception filters are allowed to be global.

308 308

const isException = parser.isException();

309 -

const normalized = normalizeRawFilter(parser, writer.properties.get('isTrusted'));

309 +

const normalized = normalizeRawFilter(parser, writer.properties.get('trustedSource'));

310 310 311 311

// Can fail if there is a mismatch with trust requirement

312 312

if ( normalized === undefined ) { return; }

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4