filename filtering for media files

No more spaces in filenames. The only allowed chars are a-z, A-Z, 0-9 and
"-_.()".

An exception are texture filenames, which may also have a prefix command
like "<decal>" included.

Also fixed some memory leaks in media download.
This commit is contained in:
ac-stef
2015-05-18 14:46:03 +02:00
parent e318ecd68e
commit 786a6cdce1
8 changed files with 71 additions and 29 deletions
+10 -7
View File
@@ -1146,21 +1146,24 @@ int downloadpackages()
bool requirepackage(int type, const char *path)
{
if(!havecurl || canceldownloads || type < 0 || type >= PCK_NUM || pendingpackages.access(path)) return false;
pckserver *source = NULL;
loopv(pckservers) if(pckservers[i]->responsive) { source = pckservers[i]; break; }
if(!source) { conoutf(_("\f3no responsive source server found, can't download")); return false; }
char *cleanpath = unixpath(newstring(path));
filtertext(cleanpath, cleanpath, FTXT__MEDIAFILEPATH);
if(strcmp(path, cleanpath)) { conoutf("refuse to download \"%s\": illegal characters", path); delstring(cleanpath); return false; }
if(!havecurl || canceldownloads || type < 0 || type >= PCK_NUM || pendingpackages.access(cleanpath)) { delstring(cleanpath); return false; }
package *pck = new package;
pck->name = unixpath(newstring(path));
pck->name = cleanpath;
pck->type = type;
loopv(pckservers) if(pckservers[i]->responsive) { pck->source = pckservers[i]; break; }
if(!pck->source) { conoutf(_("\f3no responsive source server found, can't download")); return false; }
pck->source = source;
pck->pending = true;
pendingpackages.access(pck->name, pck);
return true;
}
void writepcksourcecfg()
{
if(pckservers.length())