bugGNU Wget - Bugs: bug #60142, if stylesheet filename differs...

 
 

bug #60142: if stylesheet filename differs only after ~200 chars, the last overwrites all previous and convert-links fails

Submitter:  None
Submitted:  Sun 28 Feb 2021 06:11:34 PM UTC
   
 
Category:  Program Logic Severity:  3 - Normal
Priority:  5 - Normal Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Florian Rosenauer Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  trunk
Operating System:  Microsoft Windows Reproducibility:  Every Time
Fixed Release:  None Planned Release:  None
Regression:  None Work Required:  None
Patch Included:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 28 Feb 2021 06:11:34 PM UTC, original submission:  

I stumbled upon a bug when downloading the Wiki from https://xwing-miniatures.fandom.com/wiki/X-Wing_Miniatures_Wiki as there were much more stylesheets in the original webpage than on the local directory, and it is really easy to reproduce. The problem is, that MediaWiki or at least the implementation at fandom.com uses ONE stylesheet generator which takes all stylesheets as parameter and delivers a ONE-IN-ALL stylesheet. This exceeds ~200 chars, and then gets truncated by wget. However, there are several stylesheets which differ only after these ~200 chars. So wget link-replaces only the last of these stylesheets. The more files you download, the more likely this problem happens. Unfortunatelly as the most important central stylesheet is missing due to that, the pages render completely unusable for local use in the Browser.

To reproduce:

1. create a file wget-test.html on your php enabled webserver with this content:

<html>
<head>
<title>wget bug demo</title>
<link rel="stylesheet" href="wget-stylesheet.php?v=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890xA"/>
<link rel="stylesheet" href="wget-stylesheet.php?v=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890xB"/>
</head>
<body>
    Hello amazing wget developers!
</body>
</html>

2. create a file wget-stylesheet.php with the following content:

<?php
/* irl this would generate a CSS based on the parameters */
echo '//v=' . htmlspecialchars($_GET["v"]);
?>

p { }
body{
    color: red;
}

3. run this command:

wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --span-hosts http://localhost/wget-test/wget-test.html ==

Expected result:

three files downloaded, three files on disk, and all two <link rel="stylesheet" href="..."/> replaced.

Real result:

three files downloaded, but only two on the disk, and only the second <link rel="stylesheet" href="..."/> is replaced with the local file.

Version Information

$ wget -V
GNU Wget 1.21.1 built on cygwin.

+cares +digest +gpgme +https +ipv6 +iri +large-file +metalink +nls
+ntlm +opie +psl +ssl/gnutls

Wgetrc:
    /etc/wgetrc (system)
Locale:
    /usr/share/locale
Compile:
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
    -DLOCALEDIR="/usr/share/locale" -I.
    -I/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/src/wget-1.21.1/src
    -I../lib
    -I/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/src/wget-1.21.1/lib
    -I/usr/include/uuid -DNDEBUG -ggdb -O2 -pipe -Wall
    -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
    -fstack-protector-strong --param=ssp-buffer-size=4
    -fdebug-prefix-map=/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/build=/usr/src/debug/wget-1.21.1-1
    -fdebug-prefix-map=/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/src/wget-1.21.1=/usr/src/debug/wget-1.21.1-1
Link:
    gcc -I/usr/include/uuid -DNDEBUG -ggdb -O2 -pipe -Wall
    -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
    -fstack-protector-strong --param=ssp-buffer-size=4
    -fdebug-prefix-map=/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/build=/usr/src/debug/wget-1.21.1-1
    -fdebug-prefix-map=/home/BWI/src/cygwin/wget/wget-1.21.1-1.x86_64/src/wget-1.21.1=/usr/src/debug/wget-1.21.1-1
    -lmetalink -lcares -lpcre2-8 -luuid -lidn2 -lnettle -lgnutls -lz
    -lpsl -lgpgme ftp-opie.o gnutls.o http-ntlm.o ../lib/libgnu.a
    -liconv -lintl -lunistring

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.



Thank you for the great work on wget!

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50946:  wget-stylesheet.php added by None (151B - application/octet-stream)
file #50947:  wget-test.html added by None (832B - text/html)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-28 None Attached File- Added wget-stylesheet.php, #50946
        Attached File- Added wget-test.html, #50947

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code