Skip to content

Commit 0df3fb2

Browse files
committed
Fix #9844 (Passing empty string to requestBrowserDomains crashes client)
1 parent fc3e377 commit 0df3fb2

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

Client/cefweb/CWebCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ eURLState CWebCore::GetDomainState(const SString& strURL, bool bOutputDebug)
219219
SString CWebCore::GetDomainFromURL(const SString& strURL)
220220
{
221221
CefURLParts urlParts;
222-
if (!CefParseURL(strURL, urlParts) || !urlParts.host.str)
222+
if (strURL.empty() || !CefParseURL(strURL, urlParts) || !urlParts.host.str)
223223
return "";
224224

225225
return UTF16ToMbUTF8(urlParts.host.str);

Client/cefweb/CWebView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bool CWebView::LoadURL(const SString& strURL, bool bFilterEnabled, const SString
9393
return false;
9494

9595
CefURLParts urlParts;
96-
if (!CefParseURL(strURL, urlParts))
96+
if (strURL.empty() || !CefParseURL(strURL, urlParts))
9797
return false; // Invalid URL
9898

9999
// Are we allowed to browse this website?

Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,12 @@ int CLuaBrowserDefs::RequestBrowserDomains(lua_State* luaVM)
167167

168168
if (!argStream.HasErrors())
169169
{
170+
// Remove empty URLs
171+
pages.erase(std::remove_if(pages.begin(), pages.end(), [](const auto& url) { return url.empty(); }));
172+
170173
// Convert to domains if we got a list of URLs
171174
if (bIsURL)
172-
{
173-
for (auto& strURL : pages)
174-
{
175-
strURL = g_pCore->GetWebCore()->GetDomainFromURL(strURL);
176-
}
177-
}
175+
std::transform(pages.begin(), pages.end(), pages.begin(), [](const auto& url) { return g_pCore->GetWebCore()->GetDomainFromURL(url); });
178176

179177
WebRequestCallback callback = [=](bool bAllow, const std::unordered_set<SString>& domains) {
180178
// Test if luaVM is still available

0 commit comments

Comments
 (0)