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

Delta Between Two Patch Sets: chrome/content/elemHideEmulation.js

Issue 29367031: Issue 4684 - Allow { and } in attribute and property selectors (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Left Patch Set: Created Dec. 9, 2016, 2:07 p.m.
Right Patch Set: Add a space after the escape sequence for { and } Created Dec. 13, 2016, 4:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/filterClasses.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; 1 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/;
2 2
3 function splitSelector(selector) 3 function splitSelector(selector)
4 { 4 {
5 if (selector.indexOf(",") == -1) 5 if (selector.indexOf(",") == -1)
6 return [selector]; 6 return [selector];
7 7
8 var selectors = []; 8 var selectors = [];
9 var start = 0; 9 var start = 0;
10 var level = 0; 10 var level = 0;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 var pattern = patterns[i]; 131 var pattern = patterns[i];
132 var match = propertySelectorRegExp.exec(pattern.selector); 132 var match = propertySelectorRegExp.exec(pattern.selector);
133 if (!match) 133 if (!match)
134 continue; 134 continue;
135 135
136 var propertyExpression = match[2]; 136 var propertyExpression = match[2];
137 var regexpString; 137 var regexpString;
138 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && 138 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" &&
139 propertyExpression[propertyExpression.length - 1] == "/") 139 propertyExpression[propertyExpression.length - 1] == "/")
140 regexpString = propertyExpression.slice(1, -1) 140 regexpString = propertyExpression.slice(1, -1)
141 .replace("\\x7B", "{").replace("\\x7D", "}"); 141 .replace("\\x7B ", "{").replace("\\x7D ", "}");
Wladimir Palant 2016/12/13 14:32:16 This will incorrectly replace \x7B1234 which is a
Felix Dahlke 2016/12/13 16:04:48 Done.
142 else 142 else
143 regexpString = filterToRegExp(propertyExpression); 143 regexpString = filterToRegExp(propertyExpression);
144 144
145 this.patterns.push({ 145 this.patterns.push({
146 text: pattern.text, 146 text: pattern.text,
147 regexp: new RegExp(regexpString, "i"), 147 regexp: new RegExp(regexpString, "i"),
148 prefix: pattern.selector.substr(0, match.index), 148 prefix: pattern.selector.substr(0, match.index),
149 suffix: pattern.selector.substr(match.index + match[0].length) 149 suffix: pattern.selector.substr(match.index + match[0].length)
150 }); 150 });
151 } 151 }
152 152
153 callback(); 153 callback();
154 }.bind(this)); 154 }.bind(this));
155 }, 155 },
156 156
157 apply: function() 157 apply: function()
158 { 158 {
159 if (this.patterns.length > 0) 159 if (this.patterns.length > 0)
160 { 160 {
161 var document = this.window.document; 161 var document = this.window.document;
162 this.addSelectors(document.styleSheets); 162 this.addSelectors(document.styleSheets);
163 document.addEventListener("load", this.onLoad.bind(this), true); 163 document.addEventListener("load", this.onLoad.bind(this), true);
164 } 164 }
165 } 165 }
166 }; 166 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld