OLD | NEW |
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 Loading... |
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 RegExpFilter.typeMap.OBJECT_SUBREQUEST); |
| 839 } |
| 840 |
829 try | 841 try |
830 { | 842 { |
831 if (blocking) | 843 if (blocking) |
832 { | 844 { |
833 if (csp && Filter.invalidCSPRegExp.test(csp)) | 845 if (csp && Filter.invalidCSPRegExp.test(csp)) |
834 return new InvalidFilter(origText, "filter_invalid_csp"); | 846 return new InvalidFilter(origText, "filter_invalid_csp"); |
835 | 847 |
836 return new BlockingFilter(origText, text, contentType, matchCase, domains, | 848 return new BlockingFilter(origText, text, contentType, matchCase, domains, |
837 thirdParty, sitekeys, collapse, csp, rewrite); | 849 thirdParty, sitekeys, collapse, csp, rewrite); |
838 } | 850 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 */ | 1114 */ |
1103 function ElemHideEmulationFilter(text, domains, selector) | 1115 function ElemHideEmulationFilter(text, domains, selector) |
1104 { | 1116 { |
1105 ElemHideBase.call(this, text, domains, selector); | 1117 ElemHideBase.call(this, text, domains, selector); |
1106 } | 1118 } |
1107 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1119 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
1108 | 1120 |
1109 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1121 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
1110 type: "elemhideemulation" | 1122 type: "elemhideemulation" |
1111 }); | 1123 }); |
OLD | NEW |