Skip to content
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

Fix handling of trailing slash in dir (TmpZip) #52

Closed
wants to merge 1 commit into from

Conversation

danhunsaker
Copy link

When adding files to a TmpZip using /path/to/files/ (instead of /path/to/files), the current code throws errors about absolute paths in ZipEntry names. This is because the regex is /#{dir}\//i, which translates out to /\/path\/to\/files\/\//i, and matches (and therefore replaces) nothing.

The intended functionality is to treat /path/to/files/ differently from /path/to/files, but rather than the current implementation's "does not work" versus "add contents of dir", it's supposed to be "add contents of dir" versus "add contents and dir". This change, which is admittedly slightly hackish, fixes that.

When adding files to a TmpZip using `/path/to/files/` (instead of `/path/to/files`), the current code throws errors about absolute paths in `ZipEntry` names.  This is because the regex is `/#{dir}\//i`, which translates out to `/\/path\/to\/files\/\//i`, and matches (and therefore replaces) nothing.

The intended functionality *is* to treat `/path/to/files/` differently from `/path/to/files`, but rather than the current implementation's "does not work" versus "add contents of dir", it's supposed to be "add contents of dir" versus "add contents *and* dir".  This change, which is admittedly slightly hackish, fixes that.
@grv87
Copy link
Contributor

grv87 commented Apr 25, 2018

It seems to me that this PR still doesn't cover regexp special characters in path, e.g. +.
My PR #64 fixes the very same line, but for different bug. I'm not sure that my fix would cover this issue.

@mwrock
Copy link
Member

mwrock commented Sep 1, 2018

closing in favor of #64

@mwrock mwrock closed this Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants