From 5454abd4ec36bb36f14a0729b76dc7a4d62280f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Tue, 26 Nov 2013 19:52:50 +0100 Subject: [PATCH] Fix handling of inlined regexp since we have to double escape reverse-slashes, and consider more cases where inlined regex could be --- .../com/google/gwt/query/rebind/JsniBundleGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java index 7d44411d..7c9ab708 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java @@ -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; } -- 2.39.5