You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/04/18 17:32:35 UTC

[Bug 56430] New: Extension mapping that includes a dot in the extension does not work

https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

            Bug ID: 56430
           Summary: Extension mapping that includes a dot in the extension
                    does not work
           Product: Tomcat 7
           Version: 7.0.53
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
          Assignee: dev@tomcat.apache.org
          Reporter: smail@benjaminplocek.com

Chapter SRV.11.2 of the servlet specification defines...

    A string beginning with a '*.' prefix is used as an extension mapping.

http://download.oracle.com/otndocs/jcp/servlet-2.5-mrel2-eval-oth-JSpec/

So, this tells us, the url-pattern '*.jsp' forwards all requests ending with
'.jsp' to the mapped servlet or filtes. With this, one might also assume that
the url-pattern '*.my.txt' forwards all requests ending with 'my.txt' to the
configured servlet or filters. But the latter does not work with Tomcat.

I set up a tiny maven project, for illustrating the problem:
https://bitbucket.org/benplocek/servlet-extension-mapping-test

This project contains a Servlet and a Filter, both mapped to '.my.html':

  <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>*.my.html</url-pattern>
  </servlet-mapping>

When sending a request to /test.my.html Tomcat responds with a 404.

I also deployed this app to Jetty 9.1.4 which behaves as expected:
/test.my.html invokes the filter and also serves the servlet. Because of this I
assume this is a bug in Tomcat.

Note: Also applies to Tomcat 8.0.5.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Benjamin Plocek <sm...@benjaminplocek.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #8 from Benjamin Plocek <sm...@benjaminplocek.com> ---
Using the rewrite valve is not an enhancement. It's a workaround that doesn't
work with Tomcat 7.

Please, read my comment #3. I now see why Tomcat doesn't support extension
mappings including multiple dots. But hey, then please fix your code so that it
is consistent.

In StandardContext.java you have a method validateURLPattern which is used at
startup. For this method the String '*.my.txt' _is valid_, but when it comes to
using this pattern, it does not have an effect, because the rest of the code
seems to agree with your explanation and takes this pattern as invalid.

So, again, I REOPEN this issue and request this enhancement: Fix the check at
startup, so that it is clear why the given filter mapping with multiple dots
does not work. It's a pain, when you have to find out why your filter does not
work and you don't even get a warning in your logs.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

--- Comment #7 from Remy Maucherat <re...@apache.org> ---
As an enhancement, it should be fine to say the rewrite valve should be used.
It is a generic solution that can take care of any matching scenario, but it
would be bad to add tiny proprietary extensions however.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
This is probably a spec-clarification question, really: does * match a dot? Is
it greedy-matching? If it behaves like a Perl-compatible RE ".*" (or really any
RE ".*"), then what you'll match is ".txt" and not ".my.txt".

I agree with you that Tomcat's behavior is "surprising", at least in this case.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Konstantin Kolinko <kn...@gmail.com> ---
>From Servlet 3.1-final.pdf
Ch. 12.1 Use of URL Paths (page #12-121 ("141 of 240"))

[quote]
3. If the last segment in the URL path contains an extension (e.g. .jsp), the
servlet
container will try to match a servlet that handles requests for the extension.
An
extension is defined as the part of the last segment after the last ’.’
character.
[/quote]

In Servlet 2.5 spec that is chapter SRV.11.1

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

--- Comment #5 from Karl Peterbauer <ka...@peterbauer.cc> ---
I think both the Servlet spec and Tomcat's implementation are quite
unfortunate. Patterns like '*.jsp' or '*.my.txt' closely resemble the venerable
UNIX glob style pattern matching, and consequenty they should behave
accordingly. For example, the UNIX command "ls *.my.txt" does match a file
named "test.my.txt".

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

--- Comment #3 from Benjamin Plocek <sm...@benjaminplocek.com> ---
Ok, but then it would be great, to get any kind of a feedback when deploying
the application. When I use an invalid pattern like '/*.jsp' the server also
complains. But when I use '*.my.txt' I get no hint that something is wrong.

So I end up with a servlet-/filter-mapping that does not have any effect.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #4 from Remy Maucherat <re...@apache.org> ---
Since this is at best an enhancement, it can be considered fixed in Tomcat 8
which includes a rewrite valve that can easily do this sort of matching.

Documentation available here:
http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Benjamin Plocek <sm...@benjaminplocek.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Christopher Schultz <ch...@christopherschultz.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |INVALID

--- Comment #6 from Christopher Schultz <ch...@christopherschultz.net> ---
Thanks for the further clarification, Konstantin. I stopped reading too soon. I
see Tomcat as implementing the spec faithfully, here, so there is no bug.
Marking INVALID.

If you'd like to request an enhancement, please REOPEN this bug and state your
request.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56430] Extension mapping that includes a dot in the extension does not work

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56430

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #9 from Mark Thomas <ma...@apache.org> ---
I've extended the check for suspicious URL patterns to include *.a.b style
patterns. The fix has been applied to 8.0.x for 8.0.6 onwards and to 7.0.x for
7.0.54 onwards.

While we can't realistically detect every possible error that a user might make
when specifying a pattern this is looks like it could be a common error and the
test was simple to add.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org