mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-19 03:05:29 +02:00
Fix curl compatibility issues with colorize_url (#14615)
Also move the escape code safety check to guiOpenURL.
This commit is contained in:
@@ -42,6 +42,19 @@ GUIOpenURLMenu::GUIOpenURLMenu(gui::IGUIEnvironment* env,
|
||||
{
|
||||
}
|
||||
|
||||
static std::string maybe_colorize_url(const std::string &url)
|
||||
{
|
||||
// Forbid escape codes in URL
|
||||
if (url.find('\x1b') != std::string::npos) {
|
||||
throw std::runtime_error("URL contains escape codes");
|
||||
}
|
||||
|
||||
#ifdef HAVE_COLORIZE_URL
|
||||
return colorize_url(url);
|
||||
#else
|
||||
return url;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GUIOpenURLMenu::regenerateGui(v2u32 screensize)
|
||||
{
|
||||
@@ -70,16 +83,12 @@ void GUIOpenURLMenu::regenerateGui(v2u32 screensize)
|
||||
*/
|
||||
bool ok = true;
|
||||
std::string text;
|
||||
#ifdef USE_CURL
|
||||
try {
|
||||
text = colorize_url(url);
|
||||
text = maybe_colorize_url(url);
|
||||
} catch (const std::exception &e) {
|
||||
text = std::string(e.what()) + " (url = " + url + ")";
|
||||
ok = false;
|
||||
}
|
||||
#else
|
||||
text = url;
|
||||
#endif
|
||||
|
||||
/*
|
||||
Add stuff
|
||||
|
Reference in New Issue
Block a user