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

Add ZIP_RAW_ENTRYNAME macro #240

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,14 @@ static char *zip_name_normalize(char *name, char *const nname, size_t len) {
}

static mz_bool zip_name_match(const char *name1, const char *name2) {
size_t len2 = strlen(name2);
char *nname2 = zip_strrpl(name2, len2, '\\', '/');
char *nname2 = NULL;

#ifdef ZIP_RAW_ENTRYNAME
nname2 = STRCLONE(name2);
#else
nname2 = zip_strrpl(name2, strlen(name2), '\\', '/');
#endif

if (!nname2) {
return MZ_FALSE;
}
Expand Down Expand Up @@ -919,7 +925,12 @@ int zip_entry_open(struct zip_t *zip, const char *entryname) {
if (zip->entry.name) {
CLEANUP(zip->entry.name);
}
#ifdef ZIP_RAW_ENTRYNAME
zip->entry.name = STRCLONE(entryname);
#else
zip->entry.name = zip_strrpl(entryname, entrylen, '\\', '/');
#endif

if (!zip->entry.name) {
// Cannot parse zip entry name
return ZIP_EINVENTNAME;
Expand Down Expand Up @@ -1120,7 +1131,12 @@ int zip_entry_openbyindex(struct zip_t *zip, int index) {
if (zip->entry.name) {
CLEANUP(zip->entry.name);
}
#ifdef ZIP_RAW_ENTRYNAME
zip->entry.name = STRCLONE(pFilename);
#else
zip->entry.name = zip_strrpl(pFilename, namelen, '\\', '/');
#endif

if (!zip->entry.name) {
// local entry name is NULL
return ZIP_EINVENTNAME;
Expand Down