henrykuijpers commented on code in PR #24:
URL: 
https://github.com/apache/sling-org-apache-sling-testing-sling-mock/pull/24#discussion_r1263760741


##########
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");
     }
 
     @Override
     public @Nullable String encodeForCSSString(@Nullable String source) {
-        return source;
+        return source == null ? null : Encode.forCssString(source);
     }
 
     @Override

Review Comment:
   It would have been nice to implement filterHTML too, maybe?



##########
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:
   Would be nice to not do a regex replace here (`String.replace` accepts a 
regex as parameter) + it replaces only the first hyphen. Then again, why is 
this hyphen replace needed?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to