diff --git a/core/src/main/java/hudson/MarkupText.java b/core/src/main/java/hudson/MarkupText.java index 2a7b813659..28d88e18a4 100644 --- a/core/src/main/java/hudson/MarkupText.java +++ b/core/src/main/java/hudson/MarkupText.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -267,7 +267,7 @@ public class MarkupText extends AbstractMarkupText { */ public String toString(boolean preEscape) { if(tags.isEmpty()) - return Util.escape(text); // the most common case + return preEscape? Util.xmlEscape(text) : Util.escape(text); // the most common case Collections.sort(tags); diff --git a/core/src/test/java/hudson/MarkupTextTest.java b/core/src/test/java/hudson/MarkupTextTest.java index dbed218fc5..1b5455cf94 100644 --- a/core/src/test/java/hudson/MarkupTextTest.java +++ b/core/src/test/java/hudson/MarkupTextTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -94,5 +94,12 @@ public class MarkupTextTest extends TestCase { assertEquals("&& &",text.toString(false)); } + public void testPreEscape() { + MarkupText text = new MarkupText("Line\n2 & 3\n\n"); + assertEquals("Line\n2 & 3\n<End>\n", text.toString(true)); + text.addMarkup(4, "
"); + assertEquals("Line
\n2 & 3\n<End>\n", text.toString(true)); + } + private static final Pattern pattern = Pattern.compile("issue #([0-9]+)"); }