[epiphany/gnome-3-20] uri-helpers: Add function to convert URI to security origin
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-20] uri-helpers: Add function to convert URI to security origin
- Date: Wed, 1 Feb 2017 21:32:13 +0000 (UTC)
commit 54470fddc29c5fee60f6264fee52df743a55c15e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Dec 29 12:54:43 2016 -0600
uri-helpers: Add function to convert URI to security origin
lib/ephy-uri-helpers.c | 25 ++++++++++++++++++++++++-
lib/ephy-uri-helpers.h | 2 ++
2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index f7c3503..db637c6 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2013 Bastien Nocera <hadess hadess net>
+ * Copyright © 2016 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -280,4 +281,26 @@ ephy_uri_normalize (const char *uri_string)
return encoded_uri;
}
-/* vim: set sw=2 ts=2 sts=2 et: */
+char *
+ephy_uri_to_security_origin (const char *uri_string)
+{
+ SoupURI *uri;
+ char *result;
+
+ /* Convert to URI containing only protocol, host, and port. */
+ uri = soup_uri_new (uri_string);
+ if (uri == NULL)
+ return NULL;
+
+ if (uri->scheme == SOUP_URI_SCHEME_FILE ||
+ uri->scheme == SOUP_URI_SCHEME_DATA)
+ return NULL;
+
+ if (soup_uri_uses_default_port (uri))
+ result = g_strdup_printf ("%s://%s", uri->scheme, uri->host);
+ else
+ result = g_strdup_printf ("%s://%s:%u", uri->scheme, uri->host, uri->port);
+ soup_uri_free (uri);
+
+ return result;
+}
diff --git a/lib/ephy-uri-helpers.h b/lib/ephy-uri-helpers.h
index e7fffa1..f04af6f 100644
--- a/lib/ephy-uri-helpers.h
+++ b/lib/ephy-uri-helpers.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2013 Bastien Nocera <hadess hadess net>
+ * Copyright © 2016 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +27,7 @@ G_BEGIN_DECLS
char *ephy_remove_tracking_from_uri (const char *uri);
char *ephy_uri_decode (const char *uri);
char *ephy_uri_normalize (const char *uri);
+char *ephy_uri_to_security_origin (const char *uri);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]