summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-29 18:49:38 -0500
committerDan McGee <dan@archlinux.org>2011-08-02 08:20:34 -0400
commitcbaff216b3eca57b4fd717da53f43a6713722e95 (patch)
tree1ef21cb061959410a827c3123ca0e7a28f7610a6 /test
parent573260556db49c62f5cf751f53812b7e06c1decb (diff)
Don't trim whitespace when reading database entries
We don't write with extra or unknown whitespace, so there is little reason for us to trim it when reading either. This also fixes the hopefully never encountered "paths that start or end with spaces" issue, for which two pactests have been added. The tests also contain other evil characters that we have encountered before and handle just fine, but it doesn't hurt to ensure we don't break such support in the future. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test')
-rw-r--r--test/pacman/pmrule.py2
-rw-r--r--test/pacman/tests/remove071.py33
-rw-r--r--test/pacman/tests/sync600.py51
3 files changed, 85 insertions, 1 deletions
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index cb7ae88d..d64f5194 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -42,7 +42,7 @@ class pmrule(object):
[testname, args] = self.rule.split("=")
if testname[0] == "!":
self.false = 1
- testname = testname.lstrip("!")
+ testname = testname[1:]
[kind, case] = testname.split("_")
if "|" in args:
[key, value] = args.split("|", 1)
diff --git a/test/pacman/tests/remove071.py b/test/pacman/tests/remove071.py
new file mode 100644
index 00000000..eff70a43
--- /dev/null
+++ b/test/pacman/tests/remove071.py
@@ -0,0 +1,33 @@
+# coding=utf8
+self.description = "Remove packages with evil filenames"
+
+self.filesystem = ["usr/bin/endwithspace",
+ "spaces/name"]
+
+p1 = pmpkg("spaces")
+p1.files = ["usr/bin/endwithspace ",
+ " spaces/name"]
+self.addpkg2db("local", p1)
+
+p2 = pmpkg("unicodechars")
+# somewhat derived from FS#9906
+p2.files = ["usr/share/Märchen",
+ "usr/share/ƏƐƕƺ",
+ "usr/share/предупреждение",
+ "usr/share/סֶאבױ",
+ "usr/share/←↯↻⇈",
+ "usr/share/アヅヨヾ",
+ "usr/share/错误"]
+self.addpkg2db("local", p2)
+
+self.args = "-R %s %s" % (p1.name, p2.name)
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=%s" % p1.name)
+self.addrule("!PKG_EXIST=%s" % p2.name)
+
+for f in p1.files:
+ self.addrule("!FILE_EXIST=%s" % f)
+ self.addrule("FILE_EXIST=%s" % f.strip())
+for f in p2.files:
+ self.addrule("!FILE_EXIST=%s" % f)
diff --git a/test/pacman/tests/sync600.py b/test/pacman/tests/sync600.py
new file mode 100644
index 00000000..e0be668c
--- /dev/null
+++ b/test/pacman/tests/sync600.py
@@ -0,0 +1,51 @@
+# coding=utf8
+self.description = "Sync packages with evil filenames"
+
+self.filesystem = ["usr/bin/endwithspace",
+ "usr/bin/newendwithspace",
+ "usr/bin/disappear",
+ "spaces/name",
+ "spaces/name2"]
+
+p1 = pmpkg("spaces")
+p1.files = ["usr/bin/endwithspace ",
+ "usr/bin/disappear ",
+ " spaces/name",
+ " spaces/gone"]
+self.addpkg2db("local", p1)
+
+sp1 = pmpkg("spaces", "1.1-1")
+sp1.files = ["usr/bin/endwithspace ",
+ "usr/bin/newendwithspace ",
+ " spaces/name",
+ " spaces/name2"]
+self.addpkg2db("sync", sp1)
+
+names = ["Märchen", "ƏƐƕƺ", "предупреждение", "סֶאבױ",
+ "←↯↻⇈", "アヅヨヾ", "错误"]
+
+p2 = pmpkg("unicodechars")
+# somewhat derived from FS#9906
+p2.files = ["usr/share/%s" % name for name in names]
+self.addpkg2db("local", p2)
+
+sp2 = pmpkg("unicodechars", "2.0-1")
+sp2.files = ["usr/man/%s" % name for name in names]
+self.addpkg2db("sync", sp2)
+
+self.args = "-S %s %s" % (sp1.name, sp2.name)
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=%s|%s" % (sp1.name, sp1.version))
+self.addrule("PKG_VERSION=%s|%s" % (sp2.name, sp2.version))
+
+for f in self.filesystem:
+ self.addrule("FILE_EXIST=%s" % f)
+self.addrule("FILE_EXIST=usr/bin/endwithspace ")
+self.addrule("FILE_EXIST= spaces/name")
+self.addrule("FILE_EXIST= spaces/name2")
+self.addrule("!FILE_EXIST=usr/bin/disappear ")
+for f in p2.files:
+ self.addrule("!FILE_EXIST=%s" % f)
+for f in sp2.files:
+ self.addrule("FILE_EXIST=%s" % f)