[Flask] Flask path route variable with a dot between two forward slashes

Francisco Roque francisco at roque.com.pt
Wed Nov 25 02:17:05 EST 2015


Thank you, that was it.

I was using curl and Chrome, but the curl version I have tried resolving
the url. Using another client worked as intended.

Best,
Francisco

On Wed, Nov 25, 2015 at 2:51 AM, Rodrigo Ramírez Norambuena <
decipher.hk at gmail.com> wrote:

> I thinks is as browser resolve the URL
>
> testing with your code example like
>
>
> @app.route('/url/<path:url>', methods=['GET'])
> def get_url(url):
>     app.logger.debug(url)
>     return jsonify(
>         url= url,
>     )
>
> Log from request from a browser
> 192.168.10.1 - - [24/Nov/2015 22:46:17] "GET /url/
> http://met.no/Nyheter/Fase+C:+Ekstremv%C3%A6ret+Petra+p%C3%A5g%C3%A5r.b7C_xdrSX6.ips
> HTTP/1.1" 200 -
>
> Using  curl
>  curl '
> http://192.168.10.2:5000/url/http://met.no/Nyheter/./Fase+C:+Ekstremv%C3%A6ret+Petra+p%C3%A5g%C3%A5r.b7C_xdrSX6.ips
> '
> {
>   "url": "
> http://met.no/Nyheter/./Fase+C:+Ekstremv\u00e6ret+Petra+p\u00e5g\u00e5r.b7C_xdrSX6.ips
> "
> }%
>
> 192.168.10.1 - - [24/Nov/2015 22:46:25] "GET /url/
> http://met.no/Nyheter/./Fase+C:+Ekstremv%C3%A6ret+Petra+p%C3%A5g%C3%A5r.b7C_xdrSX6.ips
> HTTP/1.1" 200 -
>
> Regards,
>
> November 24 2015 11:06 AM, "Francisco Roque" <francisco at roque.com.pt>
> wrote:
> > Hi all,
> >
> > I am trying to capture an url from a flask request. All works fine
> except when the url has a dot in
> > between two forward slashes, for example:
> >
> > http://met.no/Nyheter/./Fase+C:+Ekstremværet+Petra+pågår.b7C_xdrSX6.ips
> <http://met.no/Nyheter/./Fase+C:+Ekstremv%C3%A6ret+Petra+p%C3%A5g%C3%A5r.b7C_xdrSX6.ips>
> >
> > The route used is below:
> >
> > @app.route('/url/<path:url>', methods=['GET'])
> > def get_url(url):
> > return url
> >
> > I understand flask is somehow resolving relative urls and ./ might mean
> the current directory, but
> > how can I make it so the url is taken as is?
> >
> > Best,
> > Francisco
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20151125/625374a1/attachment.html>


More information about the Flask mailing list