Encode based on response character encoding
Before this commit, characters were always encoded with the default encoding (i.e. ISO-8859-1). Now, the character encoding of the response is used. Closes gh-files
This commit is contained in:
@@ -96,8 +96,8 @@ class InputTagTests extends AbstractFormTagTests {
|
||||
|
||||
@Test
|
||||
void simpleBindWithHtmlEscaping() throws Exception {
|
||||
final String NAME = "Rob \"I Love Mangos\" Harrop";
|
||||
final String HTML_ESCAPED_NAME = "Rob "I Love Mangos" Harrop";
|
||||
final String NAME = "Rob \"I Love Cafés\" Harrop";
|
||||
final String HTML_ESCAPED_NAME = "Rob "I Love Cafés" Harrop";
|
||||
|
||||
this.tag.setPath("name");
|
||||
this.rob.setName(NAME);
|
||||
@@ -112,6 +112,25 @@ class InputTagTests extends AbstractFormTagTests {
|
||||
assertValueAttribute(output, HTML_ESCAPED_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void simpleBindWithHtmlEscapingAndCharacterEncoding() throws Exception {
|
||||
final String NAME = "Rob \"I Love Cafés\" Harrop";
|
||||
final String HTML_ESCAPED_NAME = "Rob "I Love Cafés" Harrop";
|
||||
|
||||
this.getPageContext().getResponse().setCharacterEncoding("UTF-8");
|
||||
this.tag.setPath("name");
|
||||
this.rob.setName(NAME);
|
||||
|
||||
assertThat(this.tag.doStartTag()).isEqualTo(Tag.SKIP_BODY);
|
||||
|
||||
String output = getOutput();
|
||||
assertTagOpened(output);
|
||||
assertTagClosed(output);
|
||||
|
||||
assertContainsAttribute(output, "type", getType());
|
||||
assertValueAttribute(output, HTML_ESCAPED_NAME);
|
||||
}
|
||||
|
||||
protected void assertValueAttribute(String output, String expectedValue) {
|
||||
assertContainsAttribute(output, "value", expectedValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user