]> source.dussan.org Git - gwtquery.git/commitdiff
Fix handling of inlined regexp since we have to double escape reverse-slashes, and...
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Tue, 26 Nov 2013 18:52:50 +0000 (19:52 +0100)
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Tue, 26 Nov 2013 18:52:50 +0000 (19:52 +0100)
gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java

index 7d44411dab58b6aafc7f8c33598b8ec4eaa8eb36..7c9ab70843b02def3dc1f767b2c925d4ba2adb55 100644 (file)
@@ -162,7 +162,7 @@ public class JsniBundleGenerator extends Generator {
 
   /**
    * Adapt a java-script block which could produce a syntax error when
-   * embedding it a a JSNI block.
+   * embedding it in a JSNI block.
    *
    * The objective is to replace any 'c' comment-ending occurrence to avoid closing
    * JSNI comment blocks prematurely.
@@ -216,7 +216,7 @@ public class JsniBundleGenerator extends Generator {
         if (!isCPPComment && !isCComment && !isRegex && !isOper) {
           isCPPComment = c == '/';
           isCComment =  c == '*';
-          isOper = !isCPPComment && !isCComment && !"=(&|".contains(""+prev);
+          isOper = !isCPPComment && !isCComment && !"=()&|\n;,\\}".contains(""+prev);
           isRegex = !isCPPComment && !isCComment && !isOper;
         }
         if (isOper) {
@@ -263,7 +263,7 @@ public class JsniBundleGenerator extends Generator {
 
   private String escapeInlineRegex(String s, String mod) {
     if (s.endsWith("*")) {
-      return "new RegExp('" + s  + "', '" + mod + "')";
+      return "new RegExp('" + s.replaceAll("\\", "\\\\")  + "','" + mod + "')";
     } else {
       return '/' + s + '/' + mod;
     }