From bf2eb381ba775312e2ae0e7175c5000e1af9a651 Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Fri, 27 Oct 2023 05:13:26 +0800 Subject: [PATCH] file_io: fix for single-file zip. --- file_io.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index 2c1664a..dbc2c18 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1274,20 +1274,9 @@ static const char *GetRelativeFileName(const char *folder, const char *path) static bool IsInSameFolder(const char *folder, const char *path) { - if (strcasestr(path, folder) == path) - { - const char *subpath = path + strlen(folder); - if (*subpath == '/') - { - subpath++; - if (*subpath != '\0') - { - const char *slash = strchr(subpath, '/'); - return !slash || *(slash + 1) == '\0'; - } - } - } - return false; + const char *p = strrchr(path, '/'); + size_t len = p ? p - path : 0; + return (strlen(folder) == len) && !strncasecmp(path, folder, len); } static int names_loaded = 0;