0

I am building a web app based on Adobe CQ 5.6.1. I have a need to use SlingHttpServletRequest.getRequestParameters(..), I also want that when i call this method i should get modified request parameters which are XSS cleaned

Now to ensure that this method returns the XSS clean data, I thought of writing a filter class which does not work as I tried to override the getRequestParameter, getRequestParameters methods. However I am unable to do as the return type is RequestParameter (or array of them). In case of HttpServletRequest, the return is String so I could return the modified String.

  1. How can I modify Sling request parameters?
  2. I was thinking that Sling request parameters are based on httpservletrequest.getParameter. Is this correct?

Please suggest.

ramesh
  • 21
  • 1
  • 3

1 Answers1

0

the way Requests and Responses works in Sling is exactly the same of the old plain JEE. If you want to override some Request parameter within a filter like in your example, you'll have to modify them and then pass along the chain of filters (if needed) a wrapped request.

See

http://sling.apache.org/apidocs/sling5/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.html

In your specific case I would suggest you to have a look at the XSS API from Granite within the CQ API. Sorry no link as it's currently giving a 503.

HTH Davide

davide
  • 232
  • 2
  • 7