From: Rudolf Polzer Date: Fri, 1 Jul 2011 10:49:31 +0000 (+0200) Subject: handle forbidden dir exclusions properly now X-Git-Tag: xonotic-v0.5.0~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=db1787bbfa16e37ceb4ef294b26832eb60f27a46;p=xonotic%2Fnetradiant.git handle forbidden dir exclusions properly now --- diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index bea0adb4..86a2ac85 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -316,10 +316,17 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules) for(j = 0; j < g_numForbiddenDirs; ++j) { - const char *p = strrchr(directory, '/'); - p = (p ? (p+1) : directory); + char* dbuf = g_strdup(directory); + if(*dbuf && dbuf[strlen(dbuf)-1] == '/') + dbuf[strlen(dbuf)-1] = 0; + const char *p = strrchr(dbuf, '/'); + p = (p ? (p+1) : dbuf); if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) + { + g_free(dbuf); break; + } + g_free(dbuf); } if(j < g_numForbiddenDirs) { @@ -382,9 +389,13 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules) if(name == 0) break; - for(j = 0; j < g_numForbiddenDirs; ++j) - if(!string_compare_nocase_upper(name, g_strForbiddenDirs[j])) - break; + for(j = 0; j < g_numForbiddenDirs; ++j) + { + const char *p = strrchr(name, '/'); + p = (p ? (p+1) : name); + if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) + break; + } if(j < g_numForbiddenDirs) continue; diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index ef2fad8a..9c75cb3a 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -161,10 +161,17 @@ void vfsInitDirectory (const char *path) for(j = 0; j < g_numForbiddenDirs; ++j) { - const char *p = strrchr(path, '/'); - p = (p ? (p+1) : path); + char* dbuf = g_strdup(path); + if(*dbuf && dbuf[strlen(dbuf)-1] == '/') + dbuf[strlen(dbuf)-1] = 0; + const char *p = strrchr(dbuf, '/'); + p = (p ? (p+1) : dbuf); if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) + { + g_free(dbuf); break; + } + g_free(dbuf); } if(j < g_numForbiddenDirs) return; @@ -193,8 +200,12 @@ void vfsInitDirectory (const char *path) break; for(j = 0; j < g_numForbiddenDirs; ++j) - if(!Q_stricmp(name, g_strForbiddenDirs[j])) + { + const char *p = strrchr(name, '/'); + p = (p ? (p+1) : name); + if(matchpattern(p, g_strForbiddenDirs[j], TRUE)) break; + } if(j < g_numForbiddenDirs) continue;