diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index dbd8b9107b22e27725c57886a28561c6716a225a..b7d76ca56a1a19c0709bc939648c4c4c313fc00a 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -807,6 +807,12 @@ public class Util { if(ch=='&') buf.append("&"); else + if(ch=='"') + buf.append("""); + else + if(ch=='\'') + buf.append("'"); + else if(ch==' ') { // All spaces in a block of consecutive spaces are converted to // non-breaking space ( ) except for the last one. This allows diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index a3fc4d9b4a263cf8acdd45f4fdcb900b2d2bbec1..f331aa5fb8de9ed14afb8129bccf2f4f7a010785 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -170,4 +170,11 @@ public class UtilTest extends TestCase { Util.deleteRecursive(d); } } + + public void TestEscape() { + assertEquals("
", Util.escape("\n")); + assertEquals("<a>", Util.escape("")); + assertEquals(""'", Util.escape("'\"")); + assertEquals("  ", Util.escape(" ")); + } }