changeset 968:d84effce2642

Manual quotation in ClasspathMatcher regex replaced by Pattern.quote
author Jiri Vanek <jvanek@redhat.com>
date Tue, 01 Apr 2014 11:27:53 +0200
parents 70d23452ac83
children 2670820a9609
files ChangeLog netx/net/sourceforge/jnlp/util/ClasspathMatcher.java
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 01 11:20:26 2014 +0200
+++ b/ChangeLog	Tue Apr 01 11:27:53 2014 +0200
@@ -1,3 +1,9 @@
+2013-04-01  Jiri Vanek  <jvanek@redhat.com>
+
+	Manual quotation in ClasspathMatcher regex replaced by Pattern.quote
+	* netx/net/sourceforge/jnlp/util/ClasspathMatcher.java: (quote)
+	is now using Pattern.quote instead manual \Q + original + \E
+
 2013-04-01  Jiri Vanek  <jvanek@redhat.com>
 
 	Restricted CodebaseMatcher to not match aaexample.com by *.example.com expression
--- a/netx/net/sourceforge/jnlp/util/ClasspathMatcher.java	Tue Apr 01 11:20:26 2014 +0200
+++ b/netx/net/sourceforge/jnlp/util/ClasspathMatcher.java	Tue Apr 01 11:27:53 2014 +0200
@@ -326,22 +326,21 @@
     private static String quote(String s) {
         /*
          * coment for lazybones:
-         * \Q is start of citation
-         * \E is end of citation
-         *  - all characters in citation are threated as are without any special meaning
+         *  Pattern.quote - all characters in citation are threated as are without any special meaning
+         *   Citation is based on \Q and \E marks wwith escapped inner \Q and \E
          * ^ is start of th e line
          * $ is end of the line
          */
         if (s.startsWith("*") && s.endsWith("*")) {
-            return "^.*\\Q" + s.substring(1, s.length() - 1) + "\\E.*$";
+            return "^.*" + Pattern.quote(s.substring(1, s.length() - 1)) + ".*$";
         } else if (s.endsWith("*")) {
-            return "^\\Q" + s.substring(0, s.length() - 1) + "\\E.*$";
+            return "^" + Pattern.quote(s.substring(0, s.length() - 1)) + ".*$";
 
         } else if (s.startsWith("*")) {
-            return "^.*\\Q" + s.substring(1) + "\\E$";
+            return "^.*" + Pattern.quote(s.substring(1)) + "$";
 
         } else {
-            return "^\\Q" + s + "\\E$";
+            return "^" + Pattern.quote(s) + "$";
         }
     }