[gnote] Fix crash when entering an URL instead of a host name for the bugzilla icon in the bugzilla addin (C
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] Fix crash when entering an URL instead of a host name for the bugzilla icon in the bugzilla addin (C
- Date: Sat, 16 May 2009 02:06:00 -0400 (EDT)
commit 94dd984337ef43d1824427381ab4b3ddcd5a1f13
Author: Hubert Figuiere <hub figuiere net>
Date: Thu May 14 14:38:17 2009 -0400
Fix crash when entering an URL instead of a host name for the bugzilla icon in the bugzilla addin (Closes #581080)
---
NEWS | 3 ++
src/addins/bugzilla/bugzillapreferences.cpp | 31 +++++++++++++++++++++++---
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index 8bb2a5f..b220f9c 100644
--- a/NEWS
+++ b/NEWS
@@ -14,10 +14,13 @@ Fixes:
* Fix build with LDFLAGS="-Wl,--as-needed" (Closes #581559)
(Priit Laes)
* '-' in note title was mistakenly doubled in the menu. (Closes #581643)
+ * Fix crash when entering an URL instead of a host name for the
+ bugzilla icon in the bugzilla addin (Closes #581080)
Translations:
* Added translations:
+ - Bengali India (bn_IN)
- Hungarian (hu)
* Updated translations:
- Arabic (ar)
diff --git a/src/addins/bugzilla/bugzillapreferences.cpp b/src/addins/bugzilla/bugzillapreferences.cpp
index 41277d7..2312f70 100644
--- a/src/addins/bugzilla/bugzillapreferences.cpp
+++ b/src/addins/bugzilla/bugzillapreferences.cpp
@@ -198,6 +198,25 @@ namespace bugzilla {
remove_button->set_sensitive(icon_tree->get_selection()->count_selected_rows() > 0);
}
+ namespace {
+
+ /** sanitize the hostname. Return false if nothing could be done */
+ bool sanitize_hostname(std::string & hostname)
+ {
+ if(sharp::string_contains(hostname, "/")
+ || sharp::string_contains(hostname, ":")) {
+ sharp::Uri uri(hostname);
+ std::string new_host = uri.get_host();
+ if(new_host.empty()) {
+ return false;
+ }
+ hostname = new_host;
+ }
+ return true;
+ }
+
+ }
+
void BugzillaPreferences::add_clicked()
{
Gtk::FileChooserDialog dialog(_("Select an icon..."),
@@ -234,8 +253,12 @@ namespace bugzilla {
icon_file = dialog.get_filename();
host = sharp::string_trim(host_entry->get_text());
+
if (response == (int) Gtk::RESPONSE_OK) {
- if(!host.empty()) {
+
+ bool valid = sanitize_hostname(host);
+
+ if(valid && !host.empty()) {
break;
}
// Let the user know that they
@@ -243,8 +266,8 @@ namespace bugzilla {
gnote::utils::HIGMessageDialog warn(
NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK,
- _("No host name specified"),
- _("You must specify the Bugzilla "
+ _("Host name invalid"),
+ _("You must specify a valid Bugzilla "
"host name to use with this icon."));
warn.run ();
@@ -288,7 +311,7 @@ namespace bugzilla {
sharp::file_copy (file_path, saved_path);
}
- catch (const sharp::Exception & e) {
+ catch (const std::exception & e) {
err_msg = e.what();
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]