[ 
https://issues.apache.org/jira/browse/SLING-12760?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dominik Smogór updated SLING-12760:
-----------------------------------
    Description: 
An OSGI early servlet filter (org.osgi.service.http.whiteboard.Preprocessor 
service) can't use getParameter* family of request methods in POST requests. 
Otherwise the sling's own x-www-form-urlencoded parser fails and sling request 
methods report 0 parameters regardless of contents of the request.

The most likely cause is the fact that request input stream is consumed by 
parameter parser of underlying servlet engine (tested with jetty on AEM 6.5) 
when called from the filter.

 

here's a piece of code to demonstrate the problem:
{code:java}
{code:java}
@Component(service = Preprocessor.class,
    immediate = true,
    property = {
        HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN + "=/",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + 
"=(osgi.http.whiteboard.context.name=*)"
    })
public class FaultyFilter implements Preprocessor {   
 @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse 
servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
        //calling this method in processor triggers the problem.
        String resource = request.getParameter("someParameter");
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
 {code}

  was:
An OSGI early servlet filter (org.osgi.service.http.whiteboard.Preprocessor 
service) can't use getParameter* family of request methods in POST requests. 
Otherwise the sling's own x-www-form-urlencoded parser fails and sling request 
methods report 0 parameters regardless of contents of the request.

The most likely cause is the fact that request input stream is consumed by 
parameter parser of underlying servlet engine when called from the filter.

 

here's a piece of code to demonstrate the problem:

{code:java}
{code:java}
@Component(service = Preprocessor.class,
    immediate = true,
    property = {
        HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN + "=/",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + 
"=(osgi.http.whiteboard.context.name=*)"
    })
public class FaultyFilter implements Preprocessor {   
 @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse 
servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
        //calling this method in processor triggers the problem.
        String resource = request.getParameter("someParameter");
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
 {code}


> Sling engine POST parameter parser is disrupted by osgi whiteboard filters 
> using parameters.
> --------------------------------------------------------------------------------------------
>
>                 Key: SLING-12760
>                 URL: https://issues.apache.org/jira/browse/SLING-12760
>             Project: Sling
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: Engine 2.7.10
>            Reporter: Dominik Smogór
>            Priority: Minor
>
> An OSGI early servlet filter (org.osgi.service.http.whiteboard.Preprocessor 
> service) can't use getParameter* family of request methods in POST requests. 
> Otherwise the sling's own x-www-form-urlencoded parser fails and sling 
> request methods report 0 parameters regardless of contents of the request.
> The most likely cause is the fact that request input stream is consumed by 
> parameter parser of underlying servlet engine (tested with jetty on AEM 6.5) 
> when called from the filter.
>  
> here's a piece of code to demonstrate the problem:
> {code:java}
> {code:java}
> @Component(service = Preprocessor.class,
>     immediate = true,
>     property = {
>         HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN + "=/",
>         HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + 
> "=(osgi.http.whiteboard.context.name=*)"
>     })
> public class FaultyFilter implements Preprocessor {   
>  @Override
>     public void doFilter(ServletRequest servletRequest, ServletResponse 
> servletResponse, FilterChain filterChain)
>         throws IOException, ServletException {
>         //calling this method in processor triggers the problem.
>         String resource = request.getParameter("someParameter");
>         filterChain.doFilter(servletRequest, servletResponse);
>     }
> }
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to