SPR-5605 spring:url tag should use htmlEscape instead of escapeXml for entity encoding
This commit is contained in:
@@ -90,7 +90,7 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
PageContext.REQUEST_SCOPE));
|
||||
}
|
||||
|
||||
public void testSetEscapeXmlDefault() throws JspException {
|
||||
public void testSetHtmlEscapeDefault() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
|
||||
@@ -112,10 +112,10 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
.getAttribute("var"));
|
||||
}
|
||||
|
||||
public void testSetEscapeXmlFalse() throws JspException {
|
||||
public void testSetHtmlEscapeFalse() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setEscapeXml("false");
|
||||
tag.setHtmlEscape("false");
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
@@ -135,10 +135,10 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
.getAttribute("var"));
|
||||
}
|
||||
|
||||
public void testSetEscapeXmlTrue() throws JspException {
|
||||
public void testSetHtmlEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setEscapeXml("true");
|
||||
tag.setHtmlEscape("true");
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
@@ -154,7 +154,54 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("url/path?n+me=v%26l%3De&name=value2", context
|
||||
assertEquals("url/path?n+me=v%26l%3De&name=value2", context
|
||||
.getAttribute("var"));
|
||||
}
|
||||
|
||||
public void testSetJavaScriptEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setJavaScriptEscape("true");
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
Param param = new Param();
|
||||
param.setName("n me");
|
||||
param.setValue("v&l=e");
|
||||
tag.addParam(param);
|
||||
|
||||
param = new Param();
|
||||
param.setName("name");
|
||||
param.setValue("value2");
|
||||
tag.addParam(param);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("url\\/path?n+me=v%26l%3De&name=value2", context
|
||||
.getAttribute("var"));
|
||||
}
|
||||
|
||||
public void testSetHtmlAndJavaScriptEscapeTrue() throws JspException {
|
||||
tag.setValue("url/path");
|
||||
tag.setVar("var");
|
||||
tag.setHtmlEscape("true");
|
||||
tag.setJavaScriptEscape("true");
|
||||
|
||||
tag.doStartTag();
|
||||
|
||||
Param param = new Param();
|
||||
param.setName("n me");
|
||||
param.setValue("v&l=e");
|
||||
tag.addParam(param);
|
||||
|
||||
param = new Param();
|
||||
param.setName("name");
|
||||
param.setValue("value2");
|
||||
tag.addParam(param);
|
||||
|
||||
tag.doEndTag();
|
||||
|
||||
assertEquals("url\\/path?n+me=v%26l%3De&name=value2", context
|
||||
.getAttribute("var"));
|
||||
}
|
||||
|
||||
@@ -521,35 +568,6 @@ public class UrlTagTests extends AbstractTagTests {
|
||||
}
|
||||
}
|
||||
|
||||
public void testEscapeXml() {
|
||||
assertEquals("<script type="text/javascript">", tag
|
||||
.escapeXml("<script type=\"text/javascript\">"));
|
||||
}
|
||||
|
||||
public void testEscapeXmlNull() {
|
||||
assertNull(tag.escapeXml(null));
|
||||
}
|
||||
|
||||
public void testEntityValueAmpersand() {
|
||||
assertEquals("&", tag.entityValue('&'));
|
||||
}
|
||||
|
||||
public void testEntityValueLessThan() {
|
||||
assertEquals("<", tag.entityValue('<'));
|
||||
}
|
||||
|
||||
public void testEntityValueGreaterThan() {
|
||||
assertEquals(">", tag.entityValue('>'));
|
||||
}
|
||||
|
||||
public void testEntityValueSingleQuote() {
|
||||
assertEquals("'", tag.entityValue('\''));
|
||||
}
|
||||
|
||||
public void testEntityValueDoubleQuote() {
|
||||
assertEquals(""", tag.entityValue('"'));
|
||||
}
|
||||
|
||||
public void testJspWriterOutput() {
|
||||
// TODO assert that the output to the JspWriter is the expected output
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user