Fixed: Ampersand in Party not displayed correctly (OFBIZ-12140)
In the reported case, ModelFormField::getDescription double HTML encodes the description when both the entity and the description contain an ampersand. A solution is to test if the description is already HTML encoded before encoding it again. If HTML encoded then only String encodes it. BTW I'm not sure it's useful but it's harmless, the same solution can be applied to OFBIZ-12026 and similarly in renderableFtlFormElementsBuilder::encode. I'll do as improvements... Thanks: Andrew Waters for report and help in analysis
This commit is contained in:
@@ -41,6 +41,7 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.apache.ofbiz.base.conversion.ConversionException;
|
||||
import org.apache.ofbiz.base.conversion.DateTimeConverters;
|
||||
import org.apache.ofbiz.base.conversion.DateTimeConverters.StringToTimestamp;
|
||||
@@ -1526,7 +1527,12 @@ public class ModelFormField {
|
||||
if (UtilValidate.isEmpty(retVal)) {
|
||||
retVal = "";
|
||||
} else if (this.getModelFormField().getEncodeOutput()) {
|
||||
UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
|
||||
UtilCodec.SimpleEncoder simpleEncoder = null;
|
||||
if (retVal.equals(StringEscapeUtils.unescapeEcmaScript(StringEscapeUtils.unescapeHtml4(retVal)))) {
|
||||
simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
|
||||
} else {
|
||||
simpleEncoder = UtilCodec.getEncoder("string");
|
||||
}
|
||||
if (simpleEncoder != null) {
|
||||
retVal = simpleEncoder.encode(retVal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user