wget 명령에 ../../../ 유지

wget 명령에 ../../../ 유지

../../../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 $ 

두 번째와 세 번째 줄은 무시해도 됩니다(URL이 실제로 존재하지 않기 때문). 하지만 첫 번째 줄에 다음과 같은 내용이 표시됩니다.

--2015-10-29 16:48:13--  http://n0t.meaning.anything:20000/some/folder/file

하지만 내 명령은

wget http://n0t.meaning.anything:20000/../../../some/folder/file

../../../따라서 내 쉘(또는 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/../../../../ghttp://a/../g(두 번째 예) 는 RFC에 따라 로 구문 분석해야 하는 와 동일합니다 http://a/g.

wget따라서 (그 문제에 대해) URI 파서는 firefox주요 구성 요소를 제거하는 데 ../정확합니다.

관련 정보