Skip to content

Commit

Permalink
Filter out unnecessary files
Browse files Browse the repository at this point in the history
  • Loading branch information
louve committed Oct 1, 2024
1 parent 1b55d88 commit e383dcf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/Components/Modules/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ namespace Components
fileEntry.name = name;
fileEntry.hash = hash;
fileEntry.size = size;
fileEntry.isMap = download->isMap_;

if (!fileEntry.name.empty())
if (!fileEntry.name.empty() && fileEntry.allowed())
{
download->files_.push_back(fileEntry);
download->totalBytes_ += fileEntry.size;
Expand All @@ -139,6 +140,8 @@ namespace Components

auto file = download->files_[index];

assert(file.allowed());

auto path = download->mod_ + "/" + file.name;
if (download->isMap_)
{
Expand Down Expand Up @@ -884,4 +887,49 @@ namespace Components
CLDownload.clear();
}
}

bool Download::ClientDownload::File::allowed() const
{
if (name.contains("..") || name.contains(":"))

Check failure on line 893 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Debug)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 893 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Debug)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 893 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 893 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]
{
return false;
}

if (name.contains("\\") || name.contains("/"))

Check failure on line 898 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Debug)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 898 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Debug)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 898 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]

Check failure on line 898 in src/Components/Modules/Download.cpp

View workflow job for this annotation

GitHub Actions / Build binaries (Release)

'contains': is not a member of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [D:\a\iw4x-client\iw4x-client\build\iw4x.vcxproj]
{
return false;
}

if (isMap)
{
if (name.ends_with(".arena"))
{
return true;
}

if (name.ends_with(".iwd"))
{
return true;
}

if (name.ends_with(".ff"))
{
return true;
}
}
else
{
// Plain and simple
if (name == "mod.ff")
{
return true;
}
if (name.ends_with(".iwd"))
{
return true;
}
}

return false;
}
}
3 changes: 3 additions & 0 deletions src/Components/Modules/Download.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ namespace Components
std::string name;
std::string hash;
std::size_t size;
bool isMap;

bool allowed() const;
};

std::vector<File> files_;
Expand Down

0 comments on commit e383dcf

Please sign in to comment.