[Python-checkins] CVS: python/dist/src/Lib zipfile.py,1.13,1.13.2.1

Anthony Baxter anthonybaxter@users.sourceforge.net
Tue, 04 Dec 2001 22:46:19 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv4876

Modified Files:
      Tag: release21-maint
	zipfile.py 
Log Message:
backport 1.15
Make sure path names inserted into ZIP files are normalized to use "/" as
the directory separator, as required by the format specification.
This closes SF bug #440693.


Index: zipfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -d -r1.13 -r1.13.2.1
*** zipfile.py	2001/04/14 16:45:14	1.13
--- zipfile.py	2001/12/05 06:46:16	1.13.2.1
***************
*** 90,94 ****
  
      def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
!         self.filename = filename        # Name of the file in the archive
          self.date_time = date_time      # year, month, day, hour, min, sec
          # Standard values:
--- 90,94 ----
  
      def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
!         self.filename = _normpath(filename) # Name of the file in the archive
          self.date_time = date_time      # year, month, day, hour, min, sec
          # Standard values:
***************
*** 129,132 ****
--- 129,143 ----
                   len(self.filename), len(self.extra))
          return header + self.filename + self.extra
+ 
+ 
+ # This is used to ensure paths in generated ZIP files always use
+ # forward slashes as the directory separator, as required by the
+ # ZIP format specification.
+ if os.sep != "/":
+     def _normpath(path):
+         return path.replace(os.sep, "/")
+ else:
+     def _normpath(path):
+         return path