Skip to content

Commit 2b287e9

Browse files
committed
fix: limit to portal2.sr domain
1 parent 68a7a38 commit 2b287e9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Features/ConfigPlus.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <unordered_set>
1414
#include <fstream>
1515
#include <curl/curl.h>
16+
#include <regex>
1617

1718
// Fuck you Windows
1819
#ifdef _WIN32
@@ -60,6 +61,14 @@ CON_COMMAND_F(sar_download_file, "sar_download_file <url> <filepath> [directory]
6061
}
6162
if (!args[1][0] || !args[2][0]) return console->Print(sar_download_file.ThisPtr()->m_pszHelpString);
6263

64+
std::string domain = std::regex_replace(args[1], std::regex("^.*://([^/?:]+)/?.*$"), "$1");
65+
66+
if (!strcmp(domain.c_str(), args[1])) return console->Print("Invalid URL.\n"); // URL is missing protocol. Reject.
67+
68+
if (domain.length() < 10 || !!strcmp(domain.c_str() + domain.length() - 10, "portal2.sr")) {
69+
return console->Print("URL domain is not portal2.sr.\n");
70+
}
71+
6372
std::string filepath = args[2];
6473
std::string gamedir = "";
6574

0 commit comments

Comments
 (0)