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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | qunit/tests/cssEscaping.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -28,7 +28,11 @@
{
var code = chr.charCodeAt(0);
- if (code <= 0x1F || code == 0x7F || /\d/.test(chr))
+ // Control characters and leading digits must be escaped based on
+ // their char code in CSS. Moreover, curly brackets aren't allowed
+ // in elemhide filters, and therefore must be escaped based on their
+ // char code as well.
+ if (code <= 0x1F || code == 0x7F || /[\d\{\}]/.test(chr))
return "\\" + code.toString(16) + " ";
return "\\" + chr;
@@ -36,7 +40,7 @@
function quote(value)
{
- return '"' + value.replace(/["\\\x00-\x1F\x7F]/g, escapeChar) + '"';
+ return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"';
}
function escapeCSS(s)
« 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