[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 17/483: Fixing escaping of attribute names

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:41:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.

commit 9200a22ec3b20e7decd7af329ce742a675ed8343
Author: Wladimir Palant <trev at gtchat.de>
Date:   Tue Jan 9 13:54:40 2007 +0000

    Fixing escaping of attribute names
    
    --HG--
    extra : convert_revision : svn%3Ad8bf93c1-8190-44a8-bb31-1ea94378a4df/trunk%40614
---
 chrome/content/composer.js | 48 ++++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index c8f7897..765fb86 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -110,32 +110,34 @@ function updateExpression() {
     for (var i = 0; i < curNode.attributes.length; i++) {
       var attr = curNode.attributes[i];
 
-      if (attr.checked && attr.selected != "") {
-        var op = "*=";
-        if (attr.selected == attr.value)
-          op = "=";
-        else if (attr.value.substr(0, attr.selected.length) == attr.selected)
-          op = "^=";
-        else if (attr.value.substr(attr.value.length - attr.selected.length) == attr.selected)
-          op = "$=";
-
-        if (/[^\w\-]/.test(attr.name) || /[()"]/.test(attr.value))
-          expressionSimple = null;
-
-        if (expressionSimple != null)
-          expressionSimple += "(" + attr.name + op + attr.value + ")";
-
+      if (attr.checked) {
         var escapedName = attr.name.replace(/([^\w\-])/g, "\\$1")
                                    .replace(/\\\{/g, "\\7B ")
                                    .replace(/\\\}/g, "\\7D ");
-        var escapedValue = attr.value.replace(/"/g, '\\"')
-                                     .replace(/\{/, "\\7B ")
-                                     .replace(/\}/, "\\7D ");
-        expressionRaw += "[" + escapedName + op + '"' + escapedValue + '"' + "]";
-      }
-      else if (attr.checked) {
-        expressionSimple = null;
-        expressionRaw += "[" + attr.name.replace(/([^\w\-])/g, "\\$1") + "]";
+        if (attr.selected != "") {
+          var op = "*=";
+          if (attr.selected == attr.value)
+            op = "=";
+          else if (attr.value.substr(0, attr.selected.length) == attr.selected)
+            op = "^=";
+          else if (attr.value.substr(attr.value.length - attr.selected.length) == attr.selected)
+            op = "$=";
+  
+          if (/[^\w\-]/.test(attr.name) || /[()"]/.test(attr.value))
+            expressionSimple = null;
+  
+          if (expressionSimple != null)
+            expressionSimple += "(" + attr.name + op + attr.value + ")";
+  
+          var escapedValue = attr.value.replace(/"/g, '\\"')
+                                      .replace(/\{/, "\\7B ")
+                                      .replace(/\}/, "\\7D ");
+          expressionRaw += "[" + escapedName + op + '"' + escapedValue + '"' + "]";
+        }
+        else {
+          expressionSimple = null;
+          expressionRaw += "[" + escapedName + "]";
+        }
       }
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list