Convert links (-k) fails with query string resources
When downloading resources with query strings attached, I find that any link to a resource containing a query string fails to be accurately converted.
In order to reproduce, I recommend using a local webserver (I'm using port 8000) with two elements, page.html
which contains the tag <img src="image.webp?some-qs"/>
, and some image file associated with that. Then executing wget2 -pk localhost:8000/page.html
ought to download both resources, and adjust the src
value of the img tag to point to the locally downloaded image. The actual result is <img src="image.webp?some-qs"/>
, which leaves the question mark intact, thus causing it to be ignored by the browser. Thus, this image actually refers to the (missing) file image.webp
, instead of the file that was downloaded, image.webp?some-qs
. In order to accurately link these files, the source attribute should be image.webp%3Fsome-qs
.
In wget1, this issue can be circumvented by adding the argument --restrict-file-names=windows
, which causes the image to be saved as image.webp@some-qs
. However, in wget2, the file is saved as image.webp%3Fsome-qs
, and referred to as src="image.webp%3Fsome-qs"
, which points not to the downloaded file, but to image.webp?some-qs
. This ought to be saved as image.webp%253Fsome-qs
.
I believe this issue might be a part of #425 (closed), however, I opened it as a new issue for a more specific part of the problem. If you'd rather that I just leave this as a comment of 425, I'd be happy to do so instead.
GNU Wget2 1.99.1 (commit 23b68e82557c9297e282b04890bf94164024648e) - multithreaded metalink/file/website downloader
+digest +https +ssl/gnutls +ipv6 +iri +large-file +nls -ntlm -opie +psl -hsts
+iconv +idn2 +zlib +lzma +brotlidec +zstd +bzip2 +http2 +gpgme
Linux <hostname> 5.1.15-arch1-1-ARCH #1 SMP PREEMPT Tue Jun 25 04:49:39 UTC 2019 x86_64 GNU/Linux