From 87b6aadbad72f1995e713ae19a3d1e7ff979a2ba Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 7 Aug 2018 10:57:00 +0100 Subject: [PATCH] Fix unescape GREL function in javascript mode. Closes #1681. --- .../com/google/refine/expr/functions/strings/Unescape.java | 2 +- .../tests/expr/functions/strings/ToFromConversionTests.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main/src/com/google/refine/expr/functions/strings/Unescape.java b/main/src/com/google/refine/expr/functions/strings/Unescape.java index 6e901b070..c3292d351 100644 --- a/main/src/com/google/refine/expr/functions/strings/Unescape.java +++ b/main/src/com/google/refine/expr/functions/strings/Unescape.java @@ -62,7 +62,7 @@ public class Unescape implements Function { } else if ("csv".equals(mode)) { return StringEscapeUtils.unescapeCsv(s); } else if ("javascript".equals(mode)) { - return StringEscapeUtils.escapeEcmaScript(s); + return StringEscapeUtils.unescapeEcmaScript(s); } else if ("url".equals(mode)) { try { return URLDecoder.decode(s,"UTF-8"); diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java index e74e025a8..374987e0d 100644 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java +++ b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/ToFromConversionTests.java @@ -177,5 +177,11 @@ public class ToFromConversionTests extends RefineTest { Assert.assertEquals(invoke("escape", Double.parseDouble("1.23"), "url"),"1.23"); Assert.assertEquals(invoke("escape", Double.parseDouble("1.23"), "javascript"),"1.23"); } + + @Test + public void testUnescape() { + Assert.assertEquals(invoke("unescape", "Ä", "html"),"Ä"); + Assert.assertEquals(invoke("unescape", "\\u00C4", "javascript"),"Ä"); + } }