On Sat, Sep 14, 2019 at 5:42 PM Christopher Schultz
<ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Alain,
>
> On 9/13/19 13:37, Alain Sellerin wrote:
> > Tomcat version: 8.5 OS: Win10, Linux
> >
> > Hi,
> >
> > I'm facing an issue with an application that is using path
> > parameters in conjunction with a RewriteValve.
> >
> > I narrowed down the problem by using the sample application
> > available here:
> > https://tomcat.apache.org/tomcat-8.5-doc/appdev/sample/
> >
> > Context ======
> >
> > 1) I modified the webapp sample.war by creating a sub directory
> > "subpath" where I copied the file hello.jsp
> >
> > The servlet URL is :
> > http://127.0.0.1:8080/sample/subpath/hello.jsp
> >
> > 2) I modified the servlet with the following code
> >
> > Request URI:          <%= request.getRequestURI() %>
> >
> > 3) I added a RewriteValve by making 2 changes in ROOT webapp a)
> > create context.xml in webapps\ROOT\META-INF with the following
> > content
> >
> > <?xml version='1.0' encoding='utf-8'?> <Context docBase="ROOT"
> > path="/" reloadable="true" crossContext="true"> <Valve
> > className="org.apache.catalina.valves.rewrite.RewriteValve"/>
> > </Context>
> >
> > b) create rewrite.config in  webapps\ROOT\WEB-INF with the
> > following content
> >
> > RewriteRule ^/foo/(.*) /sample/$1 [L]
> >
> > NB: The base of the url is rewritten to "sample" when it is equals
> > to "foo"
> >
> >
> > Description of the problem ====================
> >
> > If the request is : http://127.0.0.1:8080/sample/subpath/hello.jsp
> > The servlet response is: Request URI: /sample/subpath/hello.jsp
> >
> > It is as expected. So far no problem.
> >
> > If the request is :
> > http://127.0.0.1:8080/sample/subpath;pathparam=123/hello.jsp The
> > servlet response is: Request URI:
> > /sample/subpath;pathparam=123/hello.jsp
> >
> > It is also as expected. Path params are displayed.
> >
> > If the request is :
> > http://127.0.0.1:8080/foo/subpath;pathparam1=123/hello.jsp The
> > servlet response is: Request URI: /sample/subpath/hello.jsp
> >
> > In this case, Tomcat stripped the path param. I was expecting it to
> > be maintained after the rewriting of the URL.
> >
> > I would like to know if there is a way to preserve path parameters
> > from the URL after a rewrite or if it is a bug that I could report
> > to Bugzilla.
> >
> > Feel free to ask me any question if it is not clear enough.
>
> This sounds like a bug to me.
>
> Can you play with the path parameter a little bit to see what might be
> triggering it? You tried with "pathparam" as the name and all was
> well. Then you tried "pathparam1" and it failed. What about
> "pathparamX" where X is a random character from your keyboard.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl19CkoACgkQHPApP6U8
> pFi9mxAAlzxiDeYqP5qlRI4PKhrNFmGhqVXfi6SBv5P2lbydMSEDi5MG/t+54eH1
> TY/IgnaocZJWEeiOG4W3lESmk+++UHKK+BvnlWaZrbujTZZLSkoHleGPMQ5DW+sy
> Y1dTOSVe8kvwtfckrK42Jhi20/CNydyjb0JpdD+jXnf+qas7yEC78tWUbcTXYNsr
> lMOY7yXP7Y5dKE907nzrX44FYkNdyoNYRM3fGkRlsKB40TFn1tNPgn6Y0x4zGaOO
> ii2DGYMGxIetflvFwvZU3nfjp+L6u0e7uLGD9twsuyhgsL8oImhUssne6XEXMRzE
> 4xlb/vK8Aao9YbZuVl9RnaYhTEB6pz6ytdEhOdY9ci0xkCRJVMLEFf8Tt2y4qVmm
> pBl7vQtrpK3Mj6JCNXKra9N7A029B8/684HS+kfeUC5Q8fEHxbXJZX3kHJFXQRAd
> q7rhe5QrX0TCQumnsoil+NKGtI5HrrM3EjkRl0sXK6JYmItJMcjchh02Y+3xit43
> vp63EOJhjnGjU+mvQDjH2cqRBOXYc5kR2a7eBAkaswhDjiNY5nhJaowBpGsYruy0
> f3537ufE97PIEH+przQAVEJb37W56idGkTKrJq1XOvZNNsIjl/1AGwiFM4eZVl1d
> qI43T790I36VOg6C+rJIzY7SE0E217tiUp0/48SBn/5ORhi7/28=
> =iPM6
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>

Hi Chris,

Thank you for your return. As suggested I made a few test with
different parameters

If the request is :
http://127.0.0.1:8080/foo/subpath;pathparam1=123/hello.jsp
The servlet response is: Request URI: /sample/subpath/hello.jsp

If the request is :
http://127.0.0.1:8080/foo/subpath;pathparam=123/hello.jsp
The servlet response is: Request URI: /sample/subpath/hello.jsp

If the request is :
http://127.0.0.1:8080/foo/subpath;pathparam=123/hello.jsp
The servlet response is: Request URI: /sample/subpath/hello.jsp

If the request is :
http://127.0.0.1:8080/foo/subpath;xyz/hello.jsp
The servlet response is: Request URI: /sample/subpath/hello.jsp

In all cases, path param is stripped.

Alain

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to