From 5b6bc888f7985ee59405b993c1ffb5350a5657dd Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Sun, 30 Jun 2013 12:21:26 -0400 Subject: [PATCH] Fix template escape processing. Fixes #752. --- main/src/com/google/refine/templating/Parser.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/src/com/google/refine/templating/Parser.java b/main/src/com/google/refine/templating/Parser.java index c47996be4..7aa0fcb4a 100644 --- a/main/src/com/google/refine/templating/Parser.java +++ b/main/src/com/google/refine/templating/Parser.java @@ -48,12 +48,18 @@ public class Parser { int start = 0, current = 0; while (current < s.length() - 1) { char c = s.charAt(current); + char c2 = s.charAt(current + 1); if (c == '\\') { - current += 2; + if (c2 == '\\' || c2 == '{' || c2 == '$') { + fragments.add(new StaticFragment(s.substring(start, current).concat(Character.toString(c2)))); + start = current += 2; + } else { + // Invalid escape - just leave it in the template + current += 1; + } continue; } - char c2 = s.charAt(current + 1); if (c == '$' && c2 == '{') { int closeBrace = s.indexOf('}', current + 2); if (closeBrace > current + 1) {