Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/filterClasses.js

Issue 29793555: Issue 6704 - Prevent $rewrite filters from matching against request types that load code (Closed)
Patch Set: Created May 29, 2018, 1:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 collapse = false; 819 collapse = false;
820 else if (option == "SITEKEY" && value) 820 else if (option == "SITEKEY" && value)
821 sitekeys = value.toUpperCase(); 821 sitekeys = value.toUpperCase();
822 else if (option == "REWRITE" && value) 822 else if (option == "REWRITE" && value)
823 rewrite = value; 823 rewrite = value;
824 else 824 else
825 return new InvalidFilter(origText, "filter_unknown_option"); 825 return new InvalidFilter(origText, "filter_unknown_option");
826 } 826 }
827 } 827 }
828 828
829 // For security reasons, never match $rewrite filters
830 // against requests that might load any code to be executed.
831 if (rewrite != null)
832 {
833 if (contentType == null)
834 ({contentType} = RegExpFilter.prototype);
835 contentType &= ~(RegExpFilter.typeMap.SCRIPT |
836 RegExpFilter.typeMap.SUBDOCUMENT |
837 RegExpFilter.typeMap.OBJECT);
838 }
839
829 try 840 try
830 { 841 {
831 if (blocking) 842 if (blocking)
832 { 843 {
833 if (csp && Filter.invalidCSPRegExp.test(csp)) 844 if (csp && Filter.invalidCSPRegExp.test(csp))
834 return new InvalidFilter(origText, "filter_invalid_csp"); 845 return new InvalidFilter(origText, "filter_invalid_csp");
835 846
836 return new BlockingFilter(origText, text, contentType, matchCase, domains, 847 return new BlockingFilter(origText, text, contentType, matchCase, domains,
837 thirdParty, sitekeys, collapse, csp, rewrite); 848 thirdParty, sitekeys, collapse, csp, rewrite);
838 } 849 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 */ 1113 */
1103 function ElemHideEmulationFilter(text, domains, selector) 1114 function ElemHideEmulationFilter(text, domains, selector)
1104 { 1115 {
1105 ElemHideBase.call(this, text, domains, selector); 1116 ElemHideBase.call(this, text, domains, selector);
1106 } 1117 }
1107 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1118 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1108 1119
1109 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1120 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1110 type: "elemhideemulation" 1121 type: "elemhideemulation"
1111 }); 1122 });
OLDNEW
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld