summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarshit Shah <darnir@gnu.org>2023-05-16 00:11:25 +0200
committerDarshit Shah <git@darnir.net>2023-05-16 00:11:25 +0200
commit5409cbcee29d62536bf6f7024ec508fbfc16a721 (patch)
tree1fb3cb0316e8fb9af9cfe8ebd72c47278cf06cc7
parent0fea7bc0766d51dd24ab97ca4b34a2be544a0a03 (diff)
downloadwget-5409cbcee29d62536bf6f7024ec508fbfc16a721.tar.gz
Add new test to ensure CSS url() encoding
url() parameters in CSS cannot have spaces in them. Ensure that Wget does not do that when using --convert-links * testenv/test_css_url.py: New file * testenv/Makefile: Add test_css_url.py to tests Bug-Id: 64082
-rw-r--r--testenv/Makefile.am1
-rwxr-xr-xtestenv/test_css_url.py63
2 files changed, 64 insertions, 0 deletions
diff --git a/testenv/Makefile.am b/testenv/Makefile.am
index b34dcf3d..7a5fdbea 100644
--- a/testenv/Makefile.am
+++ b/testenv/Makefile.am
@@ -44,6 +44,7 @@ DEFAULT_TESTS = \
Test-condget.py \
Test-Content-disposition-2.py \
Test-Content-disposition.py \
+ test_css_url.py \
Test--convert-links--content-on-error.py \
Test-cookie-401.py \
Test-cookie-domain-mismatch.py \
diff --git a/testenv/test_css_url.py b/testenv/test_css_url.py
new file mode 100755
index 00000000..1c1c8f8b
--- /dev/null
+++ b/testenv/test_css_url.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+
+"""Ensure that Wget correctly encodes url() parameters in CSS."""
+
+from test.base_test import HTTP
+from test.http_test import HTTPTest
+
+from misc.wget_file import WgetFile
+
+############################## File Definitions ###############################
+FILE1 = """<html>
+ <head>
+<style>
+body {
+ background-image: url(image%201.html);
+}
+</style>
+ </head>
+ <body>Hello</body>
+</html>"""
+
+
+FILE2 = "This is an image"
+
+File1_File = WgetFile("index.html", FILE1)
+File2_File = WgetFile("image 1.html", FILE2)
+File2_ServerFile = WgetFile("image%201.html", FILE2)
+
+WGET_OPTIONS = "--recursive --convert-links --no-host-directories"
+WGET_URLS = [[""]]
+
+Servers = [HTTP]
+
+Files = [[File1_File, File2_ServerFile]]
+Existing_Files = []
+
+ExpectedReturnCode = 0
+ExpectedDownloadedFiles = [File1_File, File2_File]
+# Request_List = [["GET /",
+# "GET /image 1.html"]]
+
+################ Pre and Post Test Hooks #####################################
+pre_test = {
+ "ServerFiles" : Files,
+ "LocalFiles" : Existing_Files
+}
+test_options = {
+ "WgetCommands" : WGET_OPTIONS,
+ "Urls" : WGET_URLS
+}
+post_test = {
+ "ExpectedFiles" : ExpectedDownloadedFiles,
+ "ExpectedRetcode" : ExpectedReturnCode
+}
+
+err = HTTPTest (
+ pre_hook=pre_test,
+ test_params=test_options,
+ post_hook=post_test,
+ protocols=Servers
+).begin ()
+
+exit (err)