[epiphany] prefs/search-engine-row: Add more validation to the bang entry



commit 5b3979da6e3479f5599cb259c20224551355ec66
Author: vanadiae <vanadiae35 gmail com>
Date:   Sun Dec 26 15:46:07 2021 +0100

    prefs/search-engine-row: Add more validation to the bang entry
    
    Those extra criteria seem reasonable enough to assume.
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1052>

 src/preferences/ephy-search-engine-row.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/preferences/ephy-search-engine-row.c b/src/preferences/ephy-search-engine-row.c
index 30b0377fa..3c286200c 100644
--- a/src/preferences/ephy-search-engine-row.c
+++ b/src/preferences/ephy-search-engine-row.c
@@ -273,6 +273,16 @@ on_bang_entry_text_changed_cb (EphySearchEngineRow *row,
   /* Checks if the bang already exists */
   if (engine_from_bang && g_strcmp0 (engine_from_bang, row->saved_name) != 0) {
     set_entry_as_invalid (bang_entry, _("This shortcut is already used."));
+  } else if (strchr (bang, ' ') != NULL) {
+    set_entry_as_invalid (bang_entry, _("Search shortcuts must not contain any space."));
+  } else if (bang[0] != '\0' && /* Empty bangs are allowed if none is wanted. */
+             (!g_unichar_ispunct (g_utf8_get_char (bang)) ||
+              /* "Punctuation" covers a wide range of symbols, with some
+               * of them that obviously don't make sense at all. So make
+               * sure those aren't allowed.
+               */
+              g_utf8_strchr ("(){}[].,", -1, g_utf8_get_char (bang)))) {
+    set_entry_as_invalid (bang_entry, _("Search shortcuts should start with a symbol such as !, # or @."));
   } else {
     set_entry_as_valid (bang_entry);
     ephy_search_engine_manager_modify_engine (row->manager,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]