You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/01/06 12:53:20 UTC

[2/2] jena git commit: JENA-843 : quote replacement string to protect literal \ and $.

JENA-843 : quote replacement string to protect literal \ and $.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3d9cdd5b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3d9cdd5b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3d9cdd5b

Branch: refs/heads/master
Commit: 3d9cdd5b7bcdf502651099848fde60b1c25aae97
Parents: 9934c2c
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Jan 6 11:52:49 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Jan 6 11:52:49 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/jena/fuseki/build/TemplateFunctions.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/3d9cdd5b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/TemplateFunctions.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/TemplateFunctions.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/TemplateFunctions.java
index 41c21c5..61c4b68 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/TemplateFunctions.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/TemplateFunctions.java
@@ -22,6 +22,7 @@ import java.io.IOException ;
 import java.io.InputStream ;
 import java.util.Map ;
 import java.util.Map.Entry ;
+import java.util.regex.Matcher ;
 
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.fuseki.Fuseki ;
@@ -61,7 +62,9 @@ public class TemplateFunctions
     /** Create a template from a String */ 
     public static String templateString(String template, Map<String, String> params) {
         for ( Entry<String, String> e : params.entrySet() ) {
-            template = template.replaceAll("\\{"+e.getKey()+"\\}", e.getValue()) ;
+            // Backslashes (\) and dollar signs ($) in the replacement string have special meaning.
+            String x = Matcher.quoteReplacement(e.getValue()) ; 
+            template = template.replaceAll("\\{"+e.getKey()+"\\}", x) ;
         }
         return template ;
     }