W3C home > Mailing lists > Public > public-dap-commits@w3.org > June 2010

2009/dap/ReSpec.js/js respec.js,1.125,1.126

From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 30 Jun 2010 15:03:13 +0000
To: public-dap-commits@w3.org
Message-Id: <E1OTyoj-00053h-P8@lionel-hutz.w3.org>
Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv19333/js

Modified Files:
	respec.js 
Log Message:
buggy generation of regular expression that triggered a really weird bug in Safari's regex implementation

Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- respec.js	24 Jun 2010 12:35:54 -0000	1.125
+++ respec.js	30 Jun 2010 15:03:11 -0000	1.126
@@ -214,7 +214,7 @@
         }
         catch (e) {
             document.body.style.display = "inherit";
-            error(e);
+            error("Processing error: " + e);
         }
         document.body.style.display = "inherit";
     },
@@ -874,16 +874,15 @@
             if (a.length < b.length) return 1;
             return 0;
         });
-        var abbrRx = "(?:\\b" + aKeys.join("\\b)|(?:\\b") + "\\b)";
-                
+        var abbrRx = aKeys.length ? "|(?:\\b" + aKeys.join("\\b)|(?:\\b") + "\\b)" : "";
+        var rx = new RegExp("(\\bMUST(?:\\s+NOT)?\\b|\\bSHOULD(?:\\s+NOT)?\\b|\\bSHALL(?:\\s+NOT)?\\b|" + 
+                            "\\bMAY\\b|\\b(?:NOT\\s+)?REQUIRED\\b|\\b(?:NOT\\s+)?RECOMMENDED\\b|\\bOPTIONAL\\b|" +
+                            "(?:\\[\\[(?:!)?[A-Za-z0-9-]+\\]\\])" +
+                            abbrRx + ")");
         // PROCESSING
         var txts = sn.findNodes(".//text()", document.body);
         for (var i = 0; i < txts.length; i++) {
             var txt = txts[i];
-            var rx = new RegExp("(\\bMUST(?:\\s+NOT)?\\b|\\bSHOULD(?:\\s+NOT)?\\b|\\bSHALL(?:\\s+NOT)?\\b|" + 
-                                "\\bMAY\\b|\\b(?:NOT\\s+)?REQUIRED\\b|\\b(?:NOT\\s+)?RECOMMENDED\\b|\\bOPTIONAL\\b|" +
-                                "(?:\\[\\[(?:!)?[A-Za-z0-9-]+\\]\\])|" +
-                                abbrRx + ")");
             var subtxt = txt.data.split(rx);
             var df = sn.documentFragment();
             while (subtxt.length) {
Received on Wednesday, 30 June 2010 15:03:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 June 2010 15:03:22 GMT