diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-30 22:49:44 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-30 22:49:44 +0300 |
commit | 462003363f7a80c96142ef1cfa9930c508970870 (patch) | |
tree | 0d7607b6df9578031b5ab0f87f380655809aff3f | |
parent | b494324ec3156082380f586434ac8ec32b44c550 (diff) | |
download | minetest-462003363f7a80c96142ef1cfa9930c508970870.tar.gz minetest-462003363f7a80c96142ef1cfa9930c508970870.tar.bz2 minetest-462003363f7a80c96142ef1cfa9930c508970870.zip |
Make server ignore media files with unknown filename extensions
-rw-r--r-- | src/server.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index e9b236cc4..08813f7fa 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3905,12 +3905,25 @@ void Server::fillMediaCache() if(dirlist[j].dir) // Ignode dirs continue; std::string filename = dirlist[j].name; - // if name contains illegal characters, ignore the file + // If name contains illegal characters, ignore the file if(!string_allowed(filename, TEXTURENAME_ALLOWED_CHARS)){ - errorstream<<"Server: ignoring illegal file name: \"" + infostream<<"Server: ignoring illegal file name: \"" <<filename<<"\""<<std::endl; continue; } + // If name is not in a supported format, ignore it + const char *supported_ext[] = { + ".png", ".jpg", ".bmp", ".tga", + ".pcx", ".ppm", ".psd", ".wal", ".rgb", + ".ogg", + NULL + }; + if(removeStringEnd(filename, supported_ext) == ""){ + infostream<<"Server: ignoring unsupported file extension: \"" + <<filename<<"\""<<std::endl; + continue; + } + // Ok, attempt to load the file and add to cache std::string filepath = mediapath + DIR_DELIM + filename; // Read data std::ifstream fis(filepath.c_str(), std::ios_base::binary); |