[epiphany/pgriffis/web-extension/windows: 8/9] WebExtensions: windows.create(): Respect same privileged url list as tabs
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/pgriffis/web-extension/windows: 8/9] WebExtensions: windows.create(): Respect same privileged url list as tabs
- Date: Wed, 8 Jun 2022 17:31:53 +0000 (UTC)
commit f2c1d4112a04f027f47d355a8b355e91c51a8830
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed Jun 8 11:48:00 2022 -0500
WebExtensions: windows.create(): Respect same privileged url list as tabs
src/webextension/api/tabs.c | 9 ++++-----
src/webextension/api/tabs.h | 3 +++
src/webextension/api/windows.c | 9 +++++++--
3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/webextension/api/tabs.c b/src/webextension/api/tabs.c
index e58c37159..e295cea7f 100644
--- a/src/webextension/api/tabs.c
+++ b/src/webextension/api/tabs.c
@@ -578,9 +578,8 @@ resolve_to_absolute_url (EphyWebExtension *web_extension,
return absolute_url;
}
-static gboolean
-url_is_unprivileged (EphyWebExtension *web_extension,
- const char *url)
+gboolean
+ephy_web_extension_api_tabs_url_is_unprivileged (const char *url)
{
const char *scheme;
/* https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create */
@@ -632,7 +631,7 @@ tabs_handler_create (EphyWebExtension *self,
}
url = resolve_to_absolute_url (self, get_string_property (create_properties, "url", NULL));
- if (!url_is_unprivileged (self, url)) {
+ if (!ephy_web_extension_api_tabs_url_is_unprivileged (url)) {
g_set_error (error, WEB_EXTENSION_ERROR, WEB_EXTENSION_ERROR_INVALID_ARGUMENT, "tabs.create(): URL '%s'
is not allowed", url);
return NULL;
}
@@ -707,7 +706,7 @@ tabs_handler_update (EphyWebExtension *self,
}
new_url = resolve_to_absolute_url (self, get_string_property (update_properties, "url", NULL));
- if (!url_is_unprivileged (self, new_url)) {
+ if (!ephy_web_extension_api_tabs_url_is_unprivileged (new_url)) {
g_set_error (error, WEB_EXTENSION_ERROR, WEB_EXTENSION_ERROR_INVALID_ARGUMENT, "tabs.update(): URL '%s'
is not allowed", new_url);
return NULL;
}
diff --git a/src/webextension/api/tabs.h b/src/webextension/api/tabs.h
index ab9cc7d34..814716bdd 100644
--- a/src/webextension/api/tabs.h
+++ b/src/webextension/api/tabs.h
@@ -41,4 +41,7 @@ void ephy_web_extension_api_tabs_add_tab_to_json (EphyWebExtension *self,
EphyWindow *window,
EphyWebView *web_view);
+gboolean ephy_web_extension_api_tabs_url_is_unprivileged
+ (const char *url);
+
G_END_DECLS
diff --git a/src/webextension/api/windows.c b/src/webextension/api/windows.c
index 88b949ee8..7a68e8fe1 100644
--- a/src/webextension/api/windows.c
+++ b/src/webextension/api/windows.c
@@ -246,16 +246,21 @@ get_url_property (JSCValue *object)
return urls;
if (jsc_value_is_string (url_value)) {
- g_ptr_array_add (urls, jsc_value_to_string (url_value));
+ g_autofree char *url = jsc_value_to_string (url_value);
+ if (ephy_web_extension_api_tabs_url_is_unprivileged (url))
+ g_ptr_array_add (urls, g_steal_pointer (&url));
return urls;
}
if (jsc_value_is_array (url_value)) {
for (guint i = 0; ; i++) {
g_autoptr (JSCValue) indexed_value = jsc_value_object_get_property_at_index (url_value, i);
+ g_autofree char *url = NULL;
if (!jsc_value_is_string (indexed_value))
break;
- g_ptr_array_add (urls, jsc_value_to_string (indexed_value));
+ url = jsc_value_to_string (indexed_value);
+ if (ephy_web_extension_api_tabs_url_is_unprivileged (url))
+ g_ptr_array_add (urls, g_steal_pointer (&url));
}
return urls;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]