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

Side by Side Diff: include.postload.js

Issue 5989801094283264: Issue 1587 - Escape curly brackets for elemhide filters (Closed)
Patch Set: Call require() in IFEE instead in the setup hook Created Nov. 20, 2014, 3:47 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 | qunit/tests/cssEscaping.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 10 matching lines...) Expand all
21 var currentElement = null; 21 var currentElement = null;
22 var clickHideFilters = null; 22 var clickHideFilters = null;
23 var highlightedElementsSelector = null; 23 var highlightedElementsSelector = null;
24 var clickHideFiltersDialog = null; 24 var clickHideFiltersDialog = null;
25 var lastRightClickEvent = null; 25 var lastRightClickEvent = null;
26 26
27 function escapeChar(chr) 27 function escapeChar(chr)
28 { 28 {
29 var code = chr.charCodeAt(0); 29 var code = chr.charCodeAt(0);
30 30
31 if (code <= 0x1F || code == 0x7F || /\d/.test(chr)) 31 // Control characters and leading digits must be escaped based on
32 // their char code in CSS. Moreover, curly brackets aren't allowed
33 // in elemhide filters, and therefore must be escaped based on their
34 // char code as well.
35 if (code <= 0x1F || code == 0x7F || /[\d\{\}]/.test(chr))
32 return "\\" + code.toString(16) + " "; 36 return "\\" + code.toString(16) + " ";
33 37
34 return "\\" + chr; 38 return "\\" + chr;
35 } 39 }
36 40
37 function quote(value) 41 function quote(value)
38 { 42 {
39 return '"' + value.replace(/["\\\x00-\x1F\x7F]/g, escapeChar) + '"'; 43 return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"';
40 } 44 }
41 45
42 function escapeCSS(s) 46 function escapeCSS(s)
43 { 47 {
44 return s.replace(/^[\d\-]|[^\w\-\u0080-\uFFFF]/g, escapeChar); 48 return s.replace(/^[\d\-]|[^\w\-\u0080-\uFFFF]/g, escapeChar);
45 } 49 }
46 50
47 function supportsShadowRoot(element) 51 function supportsShadowRoot(element)
48 { 52 {
49 if (!("createShadowRoot" in element)) 53 if (!("createShadowRoot" in element))
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 break; 674 break;
671 default: 675 default:
672 sendResponse({}); 676 sendResponse({});
673 break; 677 break;
674 } 678 }
675 }); 679 });
676 680
677 if (window == window.top) 681 if (window == window.top)
678 ext.backgroundPage.sendMessage({type: "report-html-page"}); 682 ext.backgroundPage.sendMessage({type: "report-html-page"});
679 } 683 }
OLDNEW
« no previous file with comments | « no previous file | qunit/tests/cssEscaping.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld