Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Using os.path.join() is not good for zipfile paths #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DavePlater opened this issue Jul 6, 2021 · 2 comments
Closed

Using os.path.join() is not good for zipfile paths #247

DavePlater opened this issue Jul 6, 2021 · 2 comments
Labels

Comments

@DavePlater
Copy link

self._fw_xml_file = os.path.join(_FW_DIR_NAME, self._fw_xml_filename)

(Trying to use the library on windows)
Using os.join() results in funky paths like 'radio_fw\\\\XB3-24A/XB3-24A_2003-th.xml' which cannot be found and throw exceptions.
For looking at zipfile contents, i think you need to force the slash type

I changed to self._fw_xml_file = _FW_DIR_NAME + "/" + self._fw_xml_filename and the code executed fine

@DavePlater
Copy link
Author

I found this statement to back up my findings:

Within a ZIP file, pathnames use the forward slash / as separator, as required by the ZIP spec (4.4.17.1).

https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

4.4.17.1 The name of the file, with optional relative path.
The path stored MUST NOT contain a drive or
device letter, or a leading slash. All slashes
MUST be forward slashes '/' as opposed to
backwards slashes '' for compatibility with Amiga
and UNIX file systems etc. If input came from standard
input, there is no file name field.

So using os.path is the wrong thing for zip files

tatianaleon added a commit that referenced this issue Aug 12, 2021
The path separator in a zip file MUST always be '/'.
From the spec (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT):

   4.4.17 file name: (Variable)

       4.4.17.1 The name of the file, with optional relative path.
       The path stored MUST NOT contain a drive or
       device letter, or a leading slash.  All slashes
       MUST be forward slashes '/' as opposed to
       backwards slashes '\' for compatibility with Amiga
       and UNIX file systems etc.  If input came from standard
       input, there is no file name field.

#247

Signed-off-by: Tatiana Leon <[email protected]>
@tatianaleon
Copy link
Contributor

Thanks for reporting, @DavePlater. This issue is fixed in master (see commit f2d9225) and will be included in the next release.

In the meantime, you can download the source code from the master branch and install the library from there (see instructions at https://github.com/digidotcom/python-xbee/blob/master/README.rst#install-from-source).

Sorry for the inconvenience.

Best regards.

tatianaleon added a commit that referenced this issue Sep 28, 2021
The path separator in a zip file MUST always be '/'.
From the spec (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT):

   4.4.17 file name: (Variable)

       4.4.17.1 The name of the file, with optional relative path.
       The path stored MUST NOT contain a drive or
       device letter, or a leading slash.  All slashes
       MUST be forward slashes '/' as opposed to
       backwards slashes '\' for compatibility with Amiga
       and UNIX file systems etc.  If input came from standard
       input, there is no file name field.

Related to commit f2d9225

While on it, fix the 'ReadXBeeProfileSample' sample.

#247
#256

Signed-off-by: Tatiana Leon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants