简体   繁体   English

Flask路径路由参数globs在两个正斜杠之间点

[英]Flask path routing parameter globs dot between two forward slashes

I am trying to capture an url from a flask request. 我试图从烧瓶请求中捕获一个URL。 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æret+Petra+pågår.b7C_xdrSX6.ips

The route used is below: 使用的路线如下:

@app.route('/url/<path:url>', methods=['GET'])
def get_url(url):
    return url

The server is queried using curl: 使用curl查询服务器:

curl localhost:5000/url/http://met.no/Nyheter/./Fase+C:+Ekstremværet+Petra+pågår.b7C_xdrSX6.ips

And the response: 并回应:

http://met.no/Nyheter/Fase+C:+Ekstremværet+Petra+pågår.b7C_xdrSX6.ips

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? 我知道flask是以某种方式解析相对url和./可能意味着当前目录,但我怎么能这样做,所以url被视为原样?

After a response on the flask mailing list I realized some clients are trying to resolve the url before sending it through. 在烧瓶邮件列表上的响应之后,我意识到一些客户端在发送之前正试图解析该URL。

My version of curl seems to behave like that, and so does Chrome, but using CocoaRestClient for example returns the expected: 我的curl版本似乎表现得那样,Chrome也是如此,但是使用CocoaRestClient作为示例会返回预期的:

http://met.no/Nyheter/./Fase+C:+Ekstremværet+Petra+pågår.b7C_xdrSX6.ips http://met.no/Nyheter/./Fase+C:+Ekstremværet+Petra+pågår.b7C_xdrSX6.ips

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM