[PATCH 1 of 2] Datacage: Insert variable values literally into output

Wald Commits scm-commit at wald.intevation.org
Tue Aug 26 17:21:58 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1409066476 -7200
# Node ID 7021753b379770e6fae7d3f689f085ab9dde3214
# Parent  37cdfad302cbb56b370cc0b7c7d1b0aeb696c93c
Datacage: Insert variable values literally into output.

diff -r 37cdfad302cb -r 7021753b3797 artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java	Tue Aug 26 12:09:18 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java	Tue Aug 26 17:21:16 2014 +0200
@@ -1172,7 +1172,10 @@
                 result[0] = null;
                 if (frames.getStore(key, result)) {
                     m.appendReplacement(
-                        sb, result[0] != null ? result[0].toString() : "");
+                        sb,
+                        result[0] != null 
+                            ? Matcher.quoteReplacement(result[0].toString())
+                            : "");
                 }
                 else {
                     m.appendReplacement(sb, "\\${" + key + "}");
@@ -1189,7 +1192,9 @@
                 String expr = m.group(1);
                 Object result = evaluateXPath(expr, XPathConstants.STRING);
                 if (result instanceof String) {
-                    m.appendReplacement(sb, (String)result);
+                    m.appendReplacement(
+                        sb,
+                        Matcher.quoteReplacement((String)result));
                 }
                 else {
                     m.appendReplacement(sb, "");


More information about the Dive4Elements-commits mailing list