You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Henry Kuijpers (Jira)" <ji...@apache.org> on 2021/12/22 12:47:00 UTC

[jira] [Updated] (SLING-11032) @SlingServletFilter(extensions = "") not restricting filter matching to extensionless requests

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

Henry Kuijpers updated SLING-11032:
-----------------------------------
    Description: 
{code:java}
@SlingServletFilter(
    extensions = ""
    pattern = "/bin/my-servlet",
    methods = HttpConstants.METHOD_POST
)
public class MyFilter implements Filter {

}
{code}

I would expect this code to evaluate to a filter that would only match a request that has path "/bin/my-servlet", no extension and method POST. Instead, all requests match (Sling Engine acts as if there was no extension constraint configured).

I specifically don't want this filter to be called when the request is "/bin/my-servlet.json" or /bin/my-servlet.xml" for example.

Generated XML:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="x.MyFilter" configuration-policy="require" immediate="true">
  <property name="sling.filter.pattern" type="String" value="/bin/my-servlet"/>
  <property name="sling.filter.methods" type="String">POST</property>
  <property name="sling.filter.extensions" type="String"></property>
  <property name="sling.filter.scope" type="String">REQUEST</property>
  <property name="sling.filter.suffix.pattern" type="String" value=""/>
  <service>
    <provide interface="javax.servlet.Filter"/>
  </service>
  <implementation class="x.MyFilter"/>
</scr:component>
{code}

  was:

{code:java}
@SlingServletFilter(
    extensions = ""
    pattern = "/bin/my-servlet",
    methods = HttpConstants.METHOD_POST
)
public class MyFilter implements Filter {

}
{code}

I would expect this code to evaluate to a filter that would only match a request that has path "/bin/my-servlet", no extension and method POST. Instead, all requests match (Sling Engine acts as if there was no extension constraint configured).

I specifically don't want this filter to be called when the request is "/bin/my-servlet.json" or /bin/my-servlet.xml" for example.


> @SlingServletFilter(extensions = "") not restricting filter matching to extensionless requests
> ----------------------------------------------------------------------------------------------
>
>                 Key: SLING-11032
>                 URL: https://issues.apache.org/jira/browse/SLING-11032
>             Project: Sling
>          Issue Type: Bug
>            Reporter: Henry Kuijpers
>            Priority: Major
>
> {code:java}
> @SlingServletFilter(
>     extensions = ""
>     pattern = "/bin/my-servlet",
>     methods = HttpConstants.METHOD_POST
> )
> public class MyFilter implements Filter {
> }
> {code}
> I would expect this code to evaluate to a filter that would only match a request that has path "/bin/my-servlet", no extension and method POST. Instead, all requests match (Sling Engine acts as if there was no extension constraint configured).
> I specifically don't want this filter to be called when the request is "/bin/my-servlet.json" or /bin/my-servlet.xml" for example.
> Generated XML:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="x.MyFilter" configuration-policy="require" immediate="true">
>   <property name="sling.filter.pattern" type="String" value="/bin/my-servlet"/>
>   <property name="sling.filter.methods" type="String">POST</property>
>   <property name="sling.filter.extensions" type="String"></property>
>   <property name="sling.filter.scope" type="String">REQUEST</property>
>   <property name="sling.filter.suffix.pattern" type="String" value=""/>
>   <service>
>     <provide interface="javax.servlet.Filter"/>
>   </service>
>   <implementation class="x.MyFilter"/>
> </scr:component>
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)