Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improved: Improves encoding in 3 classes
Fixes an issue put in with commit c54dced

There I wrongly replaced internalEncoder in MacroFormRenderer.java by
context.get("simpleEncoder")

While at it uses the pattern used in commit cb9c366 in every place in
modelFormField class
  • Loading branch information
JacquesLeRoux committed Mar 7, 2021
1 parent 1bf977a commit 8243d92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Expand Up @@ -713,7 +713,12 @@ public String getTooltip(Map<String, Object> context) {
tooltipString = tooltip.expandString(context);
}
if (this.getEncodeOutput()) {
UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
UtilCodec.SimpleEncoder simpleEncoder = null;
if (tooltipString.equals(StringEscapeUtils.unescapeEcmaScript(StringEscapeUtils.unescapeHtml4(tooltipString)))) {
simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
} else {
simpleEncoder = UtilCodec.getEncoder("string");
}
if (simpleEncoder != null) {
tooltipString = simpleEncoder.encode(tooltipString);
}
Expand Down Expand Up @@ -1825,7 +1830,12 @@ public String getDescription(Map<String, Object> context) {
}
}
if (UtilValidate.isNotEmpty(this.description) && retVal != null && 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);
}
Expand Down Expand Up @@ -2751,7 +2761,12 @@ public FlexibleStringExpander getValue() {
public String getValue(Map<String, Object> context) {
if (UtilValidate.isNotEmpty(this.value)) {
String valueEnc = this.value.expandString(context);
UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
UtilCodec.SimpleEncoder simpleEncoder = null;
if (valueEnc.equals(StringEscapeUtils.unescapeEcmaScript(StringEscapeUtils.unescapeHtml4(valueEnc)))) {
simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
} else {
simpleEncoder = UtilCodec.getEncoder("string");
}
if (simpleEncoder != null) {
valueEnc = simpleEncoder.encode(valueEnc);
}
Expand Down
Expand Up @@ -2915,7 +2915,7 @@ public void makeHyperlinkByType(Appendable writer, String linkType, String linkS
UtilCodec.SimpleEncoder simpleEncoder = null;
String encodedDescription = null;
if (description.equals(StringEscapeUtils.unescapeEcmaScript(StringEscapeUtils.unescapeHtml4(description)))) {
simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
simpleEncoder = internalEncoder;
} else {
simpleEncoder = UtilCodec.getEncoder("string");
}
Expand Down

0 comments on commit 8243d92

Please sign in to comment.