From 5042cc69fa1470e2fa5488875230749a6538f398 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 21 Oct 2010 21:03:52 +0000 Subject: [PATCH] Let's escape HTML by default so as to avoid confusion. --- src/main/java/com/samskivert/mustache/Mustache.java | 4 ++-- src/test/java/com/samskivert/mustache/MustacheTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/samskivert/mustache/Mustache.java b/src/main/java/com/samskivert/mustache/Mustache.java index a6c3aac..6ebec9d 100644 --- a/src/main/java/com/samskivert/mustache/Mustache.java +++ b/src/main/java/com/samskivert/mustache/Mustache.java @@ -57,11 +57,11 @@ public class Mustache } /** - * Returns a compiler that does not escape HTML by default. + * Returns a compiler that escapes HTML by default. */ public static Compiler compiler () { - return new Compiler(false); + return new Compiler(true); } /** diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index b83c3d7..2183052 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -114,9 +114,10 @@ public class MustacheTest } @Test public void testEscapeHTML () { - assertEquals("", Mustache.compiler().compile("{{a}}").execute(context("a", ""))); - assertEquals("<b>", Mustache.compiler().escapeHTML(true). - compile("{{a}}").execute(context("a", ""))); + assertEquals("<b>", Mustache.compiler().compile("{{a}}"). + execute(context("a", ""))); + assertEquals("", Mustache.compiler().escapeHTML(false).compile("{{a}}"). + execute(context("a", ""))); } protected void test (String expected, String template, Object ctx)