[epiphany] history-service: skip schemas when matching urls



commit c2bdc795fe0e1259b66365c4071dd2bc5056ce89
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Fri Feb 7 19:14:04 2014 +0200

    history-service: skip schemas when matching urls
    
    Modify the matching pattern used with sqlite so that the scheme is
    skipped. We do this by prepending a '%:' to the LIKE string.
    In order to reuse this string with non-url strings (for which the
    '%:' is unnecessary, we just skip these two characters.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723855

 lib/ephy-sqlite-statement.c                     |    2 +-
 lib/history/ephy-history-service-hosts-table.c  |    3 ++-
 lib/history/ephy-history-service-urls-table.c   |    2 +-
 lib/history/ephy-history-service-visits-table.c |    2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/lib/ephy-sqlite-statement.c b/lib/ephy-sqlite-statement.c
index fb0ffd2..e1f3e07 100644
--- a/lib/ephy-sqlite-statement.c
+++ b/lib/ephy-sqlite-statement.c
@@ -255,7 +255,7 @@ ephy_sqlite_create_match_pattern (const char *match_string)
   char *string, *pattern;
 
   string = g_strndup (match_string, EPHY_SQLITE_LIMIT_LIKE_PATTERN_LENGTH - 2);
-  pattern = g_strdup_printf ("%%%s%%", string);
+  pattern = g_strdup_printf ("%%:%%%s%%", string);
   g_free (string);
 
   return pattern;
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index 0a3aa86..ce1739b 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -322,7 +322,8 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
     int j = 4;
     char *string = ephy_sqlite_create_match_pattern (substring->data);
     while (j--)
-      if (ephy_sqlite_statement_bind_string (statement, i++, string, &error) == FALSE) {
+      /* The bitwise operation ensures we only skip two characters for titles. */
+      if (ephy_sqlite_statement_bind_string (statement, i++, string + 2*((j+1) & 1), &error) == FALSE) {
         g_error ("Could not build hosts table query statement: %s", error->message);
         g_error_free (error);
         g_object_unref (statement);
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index c9c9058..881dbe6 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -337,7 +337,7 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
       g_free (string);
       return NULL;
     }
-    if (ephy_sqlite_statement_bind_string (statement, i++, string, &error) == FALSE) {
+    if (ephy_sqlite_statement_bind_string (statement, i++, string + 2, &error) == FALSE) {
       g_error ("Could not build urls table query statement: %s", error->message);
       g_error_free (error);
       g_object_unref (statement);
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index 1b9e5b3..c5b32eb 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -191,7 +191,7 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
       g_free (string);
       return NULL;
     }
-    if (ephy_sqlite_statement_bind_string (statement, i++, string, &error) == FALSE) {
+    if (ephy_sqlite_statement_bind_string (statement, i++, string + 2, &error) == FALSE) {
       g_error ("Could not build urls table query statement: %s", error->message);
       g_error_free (error);
       g_object_unref (statement);


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