Skip to content

Commit

Permalink
Add ZIP_RAW_ENTRYNAME (kuba--#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-- authored and thabetx committed Sep 7, 2023
1 parent 0043fdd commit ccdd627
Showing 1 changed file with 18 additions and 2 deletions.
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

0 comments on commit ccdd627

Please sign in to comment.