Move escaping from Attribute constructor to rendering
lambdaupb opened this issue · comments
Attribute
escapes its value in the constructor, that leads to the behaviour that Attribute.getValue()
returns escaped text.
If that text is then used to create another value or text element, it will be double escaped <
-> &lt;
@Test
public void testAttributeValueRoundtrip() throws Exception {
Attribute attributeWithValue = new Attribute("href", "<");
Attribute attributeWithValueReconstructed = new Attribute("href", attributeWithValue.getValue());
assertThat(attributeWithValueReconstructed.getValue(), is("<"));
}
java.lang.AssertionError:
Expected: is "<"
but: was "&lt;"
Expected :<
Actual :&lt;
Additionally the behaviour is inconsistent between the constructor and the setValue
method. setValue()
does not escape the text, while the constructor does.
Changing this will technically alter behaviour of existing code, but one could argue that uses like this were broken.
Changing this will technically alter behaviour of existing code, but one could argue that uses like this were broken.
Agreed. Please go ahead.