summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorJulen Ruiz Aizpuru <julenx@gmail.com>2022-04-09 21:42:04 +0200
committerTim Flynn <trflynn89@pm.me>2022-04-11 08:19:29 -0400
commit23ea5c6721e4cf71be3ffefd88cd3d9d4cc34825 (patch)
tree622a0c54a8f038271176e99c10b7effdfd7e820a /Userland/Applications
parentaf3174c9cea0a438e4f992d5d8e5087138b70dc0 (diff)
downloadserenity-23ea5c6721e4cf71be3ffefd88cd3d9d4cc34825.zip
BrowserSettings: Validate homepage URL
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp
index 0499ce63c1..208aa09fa2 100644
--- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp
+++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp
@@ -9,6 +9,7 @@
#include <LibConfig/Client.h>
#include <LibGUI/JsonArrayModel.h>
#include <LibGUI/Label.h>
+#include <LibGUI/MessageBox.h>
#include <LibGUI/Model.h>
static String default_homepage_url = "file:///res/html/misc/welcome.html";
@@ -155,8 +156,14 @@ void BrowserSettingsWidget::set_search_engine_url(StringView url)
void BrowserSettingsWidget::apply_settings()
{
- // TODO: Ensure that the URL is valid, as we do in the BrowserWindow's change-homepage dialog
- Config::write_string("Browser", "Preferences", "Home", m_homepage_url_textbox->text());
+ auto homepage_url = m_homepage_url_textbox->text();
+ if (!URL(homepage_url).is_valid()) {
+ GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid");
+ m_homepage_url_textbox->select_all();
+ m_homepage_url_textbox->set_focus(true);
+ return;
+ }
+ Config::write_string("Browser", "Preferences", "Home", homepage_url);
Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", m_show_bookmarks_bar_checkbox->is_checked());