[Zope-CVS] SVN: zpkgtools/trunk/zpkgtools/ be more careful about how we check that a relative path in an PACKAGE.txt

Fred L. Drake, Jr. fdrake at gmail.com
Thu Oct 28 01:30:49 EDT 2004


Log message for revision 28271:
  be more careful about how we check that a relative path in an PACKAGE.txt
  does not refer to some containing directory; "." should be allowed
  

Changed:
  U   zpkgtools/trunk/zpkgtools/include.py
  U   zpkgtools/trunk/zpkgtools/tests/test_include.py

-=-
Modified: zpkgtools/trunk/zpkgtools/include.py
===================================================================
--- zpkgtools/trunk/zpkgtools/include.py	2004-10-28 05:12:40 UTC (rev 28270)
+++ zpkgtools/trunk/zpkgtools/include.py	2004-10-28 05:30:48 UTC (rev 28271)
@@ -108,12 +108,15 @@
             raise InclusionSpecificationError(
                 "URLs are not allowed in inclusions")
     np = posixpath.normpath(path)
-    if posixpath.isabs(np) or np[:1] == ".":
+    if posixpath.isabs(np) or np.split("/", 1)[0] == "..":
         raise InclusionSpecificationError(
             "%s path must not be absolute or refer to a location"
             " not contained in the source directory"
             % path)
-    return np.replace("/", os.sep)
+    if np == ".":
+        return os.curdir
+    else:
+        return np.replace("/", os.sep)
 
 
 def normalize_path_or_url(path, type, group, baseurl=None):
@@ -198,6 +201,10 @@
             other = normalize_path_or_url(other, "source", section.group,
                                           self.baseurl)
         elif other:
+            # workfile and other have a backward relationship for this:
+            # <destination>
+            #   target workfile
+            # </destination>
             other = normalize_path(other, "destination", section.group)
 
         if workfile:

Modified: zpkgtools/trunk/zpkgtools/tests/test_include.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_include.py	2004-10-28 05:12:40 UTC (rev 28270)
+++ zpkgtools/trunk/zpkgtools/tests/test_include.py	2004-10-28 05:30:48 UTC (rev 28271)
@@ -253,11 +253,12 @@
         self.check_normalize_urls(normalize)
 
     def check_normalize_paths(self, normalize):
-        INCLUDES = "INCLUDES.txt"
         self.assertEqual(normalize("README.txt", "t", "group"),
                          "README.txt")
         self.assertEqual(normalize("doc/README.txt", "t", "group"),
                          join("doc", "README.txt"))
+        self.assertEqual(normalize(".", "t", "group"),
+                         os.curdir)
         # Ignore this because it looks like a Windows drive letter:
         self.assertRaises(include.InclusionSpecificationError,
                           normalize, "c:foo/bar", "t", "group")
@@ -271,7 +272,6 @@
                           normalize, "../def.txt", "t", "group")
 
     def check_normalize_urls(self, normalize):
-        INCLUDES = "INCLUDES.txt"
         for url in ("http://www.example.com/index.html",
                     "repository:/Zope3/doc",
                     "cvs://cvs.zope.com/cvs-repository:/Zope3/doc:HEAD"):



More information about the Zope-CVS mailing list