thirdparty/google_appengine/google/appengine/dist/py_zipimport.py
changeset 2864 2e0b0af889be
parent 2273 e4cb9c53db3e
equal deleted inserted replaced
2862:27971a13089f 2864:2e0b0af889be
   218     return mod
   218     return mod
   219 
   219 
   220 
   220 
   221   def get_data(self, fullpath):
   221   def get_data(self, fullpath):
   222     """Return (binary) content of a data file in the zipfile."""
   222     """Return (binary) content of a data file in the zipfile."""
   223     required_prefix = os.path.join(self.archive, '')
   223     prefix = os.path.join(self.archive, '')
   224     if not fullpath.startswith(required_prefix):
   224     if fullpath.startswith(prefix):
   225       raise IOError('Path %r doesn\'t start with zipfile name %r' %
   225       relpath = fullpath[len(prefix):]
   226                     (fullpath, required_prefix))
   226     elif os.path.isabs(fullpath):
   227     relpath = fullpath[len(required_prefix):]
   227       raise IOError('Absolute path %r doesn\'t start with zipfile name %r' %
       
   228                     (fullpath, prefix))
       
   229     else:
       
   230       relpath = fullpath
   228     try:
   231     try:
   229       return self.zipfile.read(relpath)
   232       return self.zipfile.read(relpath)
   230     except KeyError:
   233     except KeyError:
   231       raise IOError('Path %r not found in zipfile %r' %
   234       raise IOError('Path %r not found in zipfile %r' %
   232                     (relpath, self.archive))
   235                     (relpath, self.archive))