../../../
wget
当我将它与命令中的 url 一起使用时,它被删除。请看下面:
user $ wget http://n0t.meaning.anything:20000/../../../some/folder/file
--2015-10-29 16:48:13-- http://n0t.meaning.anything:20000/some/folder/file
Resolving n0t.meaning.anything (n0t.meaning.anything)... failed: Name or service not known.
wget: unable to resolve host address ‘n0t.meaning.anything’
user $
您可以忽略第二行和第三行(因为该网址实际上不存在)。但在第一行你会看到:
--2015-10-29 16:48:13-- http://n0t.meaning.anything:20000/some/folder/file
但我的命令是
wget http://n0t.meaning.anything:20000/../../../some/folder/file
所以你可以看到它../../../
是被我的 shell(或 wget 命令)删除的。
如何保留../../../
wget 命令中的内容。
答案1
我认为如果不对它们进行 URL 编码就不行。wget
删除src/url.c
它们;据我所知非常简单看一下源码,没有办法解决。
/* Resolve "." and ".." elements of PATH by destructively modifying
PATH and return true if PATH has been modified, false otherwise.
The algorithm is in spirit similar to the one described in rfc1808,
although implemented differently, in one pass. To recap, path
elements containing only "." are removed, and ".." is taken to mean
"back up one element". Single leading and trailing slashes are
preserved.
For example, "a/b/c/./../d/.." will yield "a/b/". More exhaustive
test examples are provided below. If you change anything in this
function, run test_path_simplify to make sure you haven't broken a
test case. */
答案2
RFC3986 §5.4.2(感谢@phk)指出:
解析器在处理相对路径引用中的“..”段多于基本 URI 路径中的层次级别的情况时必须小心。请注意,“..”语法不能用于更改 URI 的权限部分。
"../../../g" = "http://a/g" "../../../../g" = "http://a/g"
上面的示例使用基本 URI http://a/b/c/d;p?q
。
http://a/b/c/d/../../../../g
(第二个示例)相当于http://a/../g
,它(根据 RFC)必须解析为http://a/g
。
wget
因此(就此而言)的 URI 解析器firefox
在剥离主要../
组件方面是正确的