You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "rubnig (via GitHub)" <gi...@apache.org> on 2023/07/14 14:02:09 UTC
[GitHub] [sling-org-apache-sling-testing-sling-mock] rubnig commented on a diff in pull request #24: SLING-10391 Implement encoding methods
rubnig commented on code in PR #24:
URL: https://github.com/apache/sling-org-apache-sling-testing-sling-mock/pull/24#discussion_r1263774621
##########
core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSAPIImpl.java:
##########
@@ -127,32 +128,32 @@ public String getValidXML(@Nullable String xml, @Nullable String defaultXml) {
@Override
public @Nullable String encodeForHTML(@Nullable String source) {
- return source;
+ return source == null ? null : Encode.forHtml(source);
}
@Override
public @Nullable String encodeForHTMLAttr(@Nullable String source) {
- return source;
+ return source == null ? null : Encode.forHtmlAttribute(source);
}
@Override
public @Nullable String encodeForXML(@Nullable String source) {
- return source;
+ return source == null ? null : Encode.forXml(source);
}
@Override
public @Nullable String encodeForXMLAttr(@Nullable String source) {
- return source;
+ return source == null ? null : Encode.forXmlAttribute(source);
}
@Override
public @Nullable String encodeForJSString(@Nullable String source) {
- return source;
+ return source == null ? null : Encode.forJavaScript(source).replace("\\-", "\\u002D");
Review Comment:
It was part of https://issues.apache.org/jira/browse/SLING-5946 and this is how it is done in https://github.com/apache/sling-org-apache-sling-xss/blame/b4c305a741cfe5a9ebad0e3c63f104ad1768d2e9/src/main/java/org/apache/sling/xss/impl/XSSAPIImpl.java#L401
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org