sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1609653 - /sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java
Date Fri, 11 Jul 2014 08:50:59 GMT
Author: bdelacretaz
Date: Fri Jul 11 08:50:59 2014
New Revision: 1609653

URL: http://svn.apache.org/r1609653
Log:
SLING-3754 - allow crank files to escape replacement of variables - patch contributed by Artyom
Stetsenko, thanks!

Modified:
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java?rev=1609653&r1=1609652&r2=1609653&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartParserImpl.java
Fri Jul 11 08:50:59 2014
@@ -57,6 +57,7 @@ class ParserException extends RuntimeExc
 
 class CmdIterator implements Iterator<CrankstartCommandLine> {
 
+    private static final char ESCAPE = '$';
     private String line;
     private final BufferedReader input;
     private final CrankstartParserImpl parser;
@@ -84,7 +85,11 @@ class CmdIterator implements Iterator<Cr
         final StringBuffer b = new StringBuffer();
         final Matcher m = varPattern.matcher(line);
         while(m.find()) {
-            m.appendReplacement(b, getValue(m.group(1)));
+            if (m.start() > 0 && line.charAt(m.start() - 1) != ESCAPE) {
+                m.appendReplacement(b, Matcher.quoteReplacement(getValue(m.group(1))));
+            } else {
+                m.appendReplacement(b, m.group().substring(1));
+            }
         }
         m.appendTail(b);
         return b.toString();



Mime
View raw message