[epiphany] Sanitize passwords from URLs before saving to history database
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Sanitize passwords from URLs before saving to history database
- Date: Mon, 17 Oct 2016 16:41:46 +0000 (UTC)
commit cbd0f2b43d468df2e7e3114d41787567bab57220
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Oct 17 08:24:34 2016 -0500
Sanitize passwords from URLs before saving to history database
lib/ephy-uri-helpers.c | 18 +++++++++++++++---
lib/ephy-uri-helpers.h | 1 +
lib/history/ephy-history-service.c | 8 +++++++-
3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 857a2f9..a597a23 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -264,11 +264,10 @@ ephy_uri_decode (const char *uri_string)
}
char *
-ephy_uri_decode_and_sanitize (const char *uri_string)
+ephy_uri_sanitize (const char *uri_string)
{
SoupURI *uri;
char *sanitized_uri;
- char *result;
/* Trick: the parameter does not actually have to be a URI. We allow calling
* this function with any address, like about:blank. Just return in that case.
@@ -279,10 +278,23 @@ ephy_uri_decode_and_sanitize (const char *uri_string)
/* Use soup_uri_to_string to remove the password component of the URI. */
sanitized_uri = soup_uri_to_string (uri, FALSE);
+ soup_uri_free (uri);
+
+ return sanitized_uri;
+}
+
+char *
+ephy_uri_decode_and_sanitize (const char *uri_string)
+{
+
+ char *sanitized_uri;
+ char *result;
+
+ sanitized_uri = ephy_uri_sanitize (uri_string);
result = ephy_uri_decode (sanitized_uri);
g_free (sanitized_uri);
- soup_uri_free (uri);
+
return result;
}
diff --git a/lib/ephy-uri-helpers.h b/lib/ephy-uri-helpers.h
index dfdfbf3..02bf094 100644
--- a/lib/ephy-uri-helpers.h
+++ b/lib/ephy-uri-helpers.h
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
char *ephy_remove_tracking_from_uri (const char *uri);
+char *ephy_uri_sanitize (const char *uri);
char *ephy_uri_decode_and_sanitize (const char *uri);
char *ephy_uri_normalize (const char *uri);
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 6c82ac5..c5256fc 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -25,6 +25,7 @@
#include "ephy-history-types.h"
#include "ephy-history-type-builtins.h"
#include "ephy-sqlite-connection.h"
+#include "ephy-uri-helpers.h"
typedef gboolean (*EphyHistoryServiceMethod) (EphyHistoryService *self, gpointer data, gpointer
*result);
@@ -1293,13 +1294,16 @@ ephy_history_service_visit_url (EphyHistoryService *self,
EphyHistoryPageVisitType visit_type)
{
EphyHistoryPageVisit *visit;
+ char *sanitized_uri;
g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
g_return_if_fail (url != NULL);
g_signal_emit (self, signals[VISIT_URL], 0, url, visit_type);
- visit = ephy_history_page_visit_new (url,
+ sanitized_uri = ephy_uri_sanitize (url);
+
+ visit = ephy_history_page_visit_new (sanitized_uri,
time (NULL),
visit_type);
ephy_history_service_add_visit (self,
@@ -1307,6 +1311,8 @@ ephy_history_service_visit_url (EphyHistoryService *self,
ephy_history_page_visit_free (visit);
ephy_history_service_queue_urls_visited (self);
+
+ g_free (sanitized_uri);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]