【问题标题】:What happens if i have ./ or ../ or .../ in my url?如果我的网址中有 ./ 或 ../ 或 .../ 会发生什么?
【发布时间】:2020-03-02 14:09:14
【问题描述】:

假设我们有如下所示的网址

  1. http://localhost:8080/sample/url/./something?queryparam=something
  2. http://localhost:8080/sample/url/../something?queryparam=something
  3. http://localhost:8080/sample/url/.../something?queryparam=something

这些是有效的 url,可以获取一些响应。 但是只有第三个 Url 被正确命中,命中后的前两个被更改为

http://localhost:8080/sample/url/something?queryparam=something(它删除了'./')

http://localhost:8080/sample/url/something?queryparam=something(它删除了'../')

但适用于第三个网址。

这里怎么逃跑了?

【问题讨论】:

    标签: http url encoding https escaping


    【解决方案1】:

    第二个实际上应该被评估为:

    http://localhost:8080/sample/something?queryparam=something

    您在此处看到的是相对分辨率的结果,尤其是https://www.greenbytes.de/tech/webdav/rfc3986.html#relative-dot-segments

    如果你想要文字“。”或 URI 中的“..”,您必须对它们进行百分比转义。

    【讨论】:

    • 是的,第二个按照您的评论进行评估。
    • 即使我对它们进行百分比编码,它的行为也是一样的。我尝试使用相同的 Urls 替换 .使用百分比编码点 -> %2E 它仅适用于第三个 Url。
    猜你喜欢
    • 1970-01-01
    • 2012-09-28
    • 2012-02-15
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    • 2020-07-20
    • 1970-01-01
    相关资源
    最近更新 更多