Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: Extended HTML Sanitizer (OFBIZ-12653) #843

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,16 @@ public void closeDocument() {
}
m.appendTail(out);
value = out.toString();
String valueUnescapeHtml4 = StringEscapeUtils.unescapeHtml4(value);
String valueUnescapeEcmaScriptAndHtml4 = StringEscapeUtils.unescapeEcmaScript(valueUnescapeHtml4);

String filtered = policy.sanitize(value);
String unescapeHtml4 = StringEscapeUtils.unescapeHtml4(filtered);
String unescapeEcmaScriptAndHtml4 = StringEscapeUtils.unescapeEcmaScript(unescapeHtml4);
String filteredUnescapeHtml4 = StringEscapeUtils.unescapeHtml4(filtered);
String filteredUnescapeEcmaScriptAndHtml4 = StringEscapeUtils.unescapeEcmaScript(filteredUnescapeHtml4);
// Replaces possible quotes entities in value (due to HtmlSanitizer above) to avoid issue with
// testCreateCustRequestItemNote and allow saving when using quotes in fields
// Maybe later we will figure out that some more HTML entities will need to be added to here, see OFBIZ-12691
if (filtered != null && !value.replace("'", "'").replace(""", "\"").replace("@", "@").equals(unescapeEcmaScriptAndHtml4)) {

if (filtered != null && !valueUnescapeEcmaScriptAndHtml4.equals(filteredUnescapeEcmaScriptAndHtml4)) {
String issueMsg = null;
if (locale.equals(new Locale("test"))) { // labels are not available in testClasses Gradle task
issueMsg = "In field [" + valueName + "] by our input policy, your input has not been accepted "
Expand Down
Loading