Rev 208: Added test for backreferencing paths. in http://bzr.daniel-watkins.co.uk/pqm/abstract-patch

Daniel Watkins daniel at daniel-watkins.co.uk
Tue Jul 22 19:10:05 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/abstract-patch

------------------------------------------------------------
revno: 208
revision-id: daniel at daniel-watkins.co.uk-20080722180836-duk15azwrfjveity
parent: daniel at daniel-watkins.co.uk-20080722180606-jin7oe29x63yhx8s
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: abstract-patch
timestamp: Tue 2008-07-22 19:08:36 +0100
message:
  Added test for backreferencing paths.
-------------- next part --------------
=== modified file 'pqm/script.py'
--- a/pqm/script.py	2008-07-22 17:34:26 +0000
+++ b/pqm/script.py	2008-07-22 18:08:36 +0000
@@ -739,8 +739,9 @@
                 filenames.insert(0, line[4:].strip())
         for filename in filenames:
             if (filename.find('/..') > 0) or (filename.find('../') > 0):
-                msg = "Invalid backreferencing filename in patch: %s"
-                raise PQMException(self.sender, msg, filename)
+                msg = ("Invalid backreferencing filename in patch: %s"
+                        % (filename,))
+                raise PQMException(self.sender, msg)
             elif filename[0] == '/':
                 msg = "Invalid absolute filename in patch: %s" % (filename,)
                 raise PQMException(self.sender, msg)

=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-22 18:06:06 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-22 18:08:36 +0000
@@ -414,6 +414,21 @@
                          " 16:06:48.000000000 +0100'",
                          str(e))
 
+    def test_PatchCommand_backreferencing_path(self):
+        configp, tree = self.set_up()
+        patch = ["=== modified file 'bar'",
+            "--- bar/.. 2008-07-20 16:06:44.000000000 +0100",
+            "+++ bar/.. 2008-07-20 16:06:48.000000000 +0100",
+            "@@ -0,0 +1 @@",
+            "+foo"]
+        script = MockScript()
+        handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
+        command = PatchCommand(script, handler, configp, patch, 'foo')
+        e = self.assertRaises(PQMException, command.run)
+        self.assertEqual("'Invalid backreferencing filename in patch: bar/.."
+                         " 2008-07-20 16:06:48.000000000 +0100'",
+                         str(e))
+
 
 class FunctionalTestCommandRunner(unittest.TestCase):
 



More information about the bazaar-commits mailing list