[evolution] I#1349 - Do not expose source WebKit data dir in installed binaries
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1349 - Do not expose source WebKit data dir in installed binaries
- Date: Tue, 9 Mar 2021 10:22:51 +0000 (UTC)
commit 41fdb88c929a173a21dde3b5ee97fe53fa8ee6c5
Author: Milan Crha <mcrha redhat com>
Date: Tue Mar 9 11:21:28 2021 +0100
I#1349 - Do not expose source WebKit data dir in installed binaries
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1349
src/e-util/CMakeLists.txt | 2 +-
src/e-util/e-web-view.c | 8 +++++++-
src/e-util/test-html-editor-units.c | 1 +
src/e-util/test-html-editor.c | 1 +
src/e-util/test-web-view-jsc.c | 1 +
src/modules/webkit-editor/CMakeLists.txt | 1 -
src/modules/webkit-editor/e-webkit-editor.c | 7 ++++++-
src/modules/webkit-editor/web-extension/CMakeLists.txt | 1 -
.../webkit-editor/web-extension/e-editor-web-extension.c | 16 ++++++++++++----
src/web-extensions/CMakeLists.txt | 1 -
src/web-extensions/e-web-extension.c | 16 ++++++++++++----
11 files changed, 41 insertions(+), 14 deletions(-)
---
diff --git a/src/e-util/CMakeLists.txt b/src/e-util/CMakeLists.txt
index 5c48fccd00..f31f678ff8 100644
--- a/src/e-util/CMakeLists.txt
+++ b/src/e-util/CMakeLists.txt
@@ -617,7 +617,6 @@ target_compile_definitions(evolution-util PRIVATE
-DEVOLUTION_RULEDIR=\"${privdatadir}\"
-DEVOLUTION_WEB_EXTENSIONS_DIR=\"${webextensionsdir}\"
-DEVOLUTION_WEBKITDATADIR=\"${webkitdatadir}\"
- -DEVOLUTION_SOURCE_WEBKITDATADIR=\"${CMAKE_SOURCE_DIR}/data/webkit\"
-DEVOLUTION_TESTGIOMODULESDIR=\"${CMAKE_CURRENT_BINARY_DIR}\"
-DEVOLUTION_TESTTOPSRCDIR=\"${CMAKE_SOURCE_DIR}\"
-DLIBEUTIL_COMPILATION
@@ -753,6 +752,7 @@ macro(add_private_program _name _sources)
-DEVOLUTION_ICONDIR=\"${icondir}\"
-DEVOLUTION_LOCALEDIR=\"${LOCALE_INSTALL_DIR}\"
-DEVOLUTION_MODULEDIR=\"${moduledir}\"
+ -DEVOLUTION_SOURCE_WEBKITDATADIR=\"${CMAKE_SOURCE_DIR}/data/webkit\"
-DEVOLUTION_TESTGIOMODULESDIR=\"${CMAKE_CURRENT_BINARY_DIR}/test-gio-modules\"
-DEVOLUTION_TESTTOPSRCDIR=\"${CMAKE_SOURCE_DIR}\"
-DLIBEUTIL_COMPILATION
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index 07642978c0..1146469c19 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -1048,6 +1048,9 @@ web_view_constructor (GType type,
if (!web_context) {
GSList *link;
+ #ifdef ENABLE_MAINTAINER_MODE
+ const gchar *source_webkitdatadir;
+ #endif
web_context = webkit_web_context_new ();
@@ -1055,8 +1058,11 @@ web_view_constructor (GType type,
webkit_web_context_set_web_extensions_directory (web_context,
EVOLUTION_WEB_EXTENSIONS_DIR);
webkit_web_context_set_sandbox_enabled (web_context, TRUE);
webkit_web_context_add_path_to_sandbox (web_context, EVOLUTION_WEBKITDATADIR,
TRUE);
+
#ifdef ENABLE_MAINTAINER_MODE
- webkit_web_context_add_path_to_sandbox (web_context,
EVOLUTION_SOURCE_WEBKITDATADIR, TRUE);
+ source_webkitdatadir = g_getenv ("EVOLUTION_SOURCE_WEBKITDATADIR");
+ if (source_webkitdatadir && *source_webkitdatadir)
+ webkit_web_context_add_path_to_sandbox (web_context,
source_webkitdatadir, TRUE);
#endif
g_object_weak_ref (G_OBJECT (web_context), web_view_web_context_gone,
&web_context);
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index d97ea2a5b8..189d9ec196 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -7594,6 +7594,7 @@ main (gint argc,
g_setenv ("GIO_EXTRA_MODULES", EVOLUTION_TESTGIOMODULESDIR, TRUE);
g_setenv ("GSETTINGS_BACKEND", TEST_KEYFILE_SETTINGS_BACKEND_NAME, TRUE);
g_setenv ("E_HTML_EDITOR_TEST_SOURCES", "1", FALSE);
+ g_setenv ("EVOLUTION_SOURCE_WEBKITDATADIR", EVOLUTION_SOURCE_WEBKITDATADIR, FALSE);
g_setenv (TEST_KEYFILE_SETTINGS_FILENAME_ENVVAR, test_keyfile_filename, TRUE);
g_test_init (&argc, &argv, NULL);
diff --git a/src/e-util/test-html-editor.c b/src/e-util/test-html-editor.c
index 995700859e..abaf54b87d 100644
--- a/src/e-util/test-html-editor.c
+++ b/src/e-util/test-html-editor.c
@@ -707,6 +707,7 @@ main (gint argc,
application = g_application_new ("org.gnome.Evolution.test-html-editor", G_APPLICATION_FLAGS_NONE);
g_setenv ("E_HTML_EDITOR_TEST_SOURCES", "1", FALSE);
+ g_setenv ("EVOLUTION_SOURCE_WEBKITDATADIR", EVOLUTION_SOURCE_WEBKITDATADIR, FALSE);
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), EVOLUTION_ICONDIR);
diff --git a/src/e-util/test-web-view-jsc.c b/src/e-util/test-web-view-jsc.c
index 53c503df76..ba41c7c9d1 100644
--- a/src/e-util/test-web-view-jsc.c
+++ b/src/e-util/test-web-view-jsc.c
@@ -3067,6 +3067,7 @@ main (gint argc,
g_test_bug_base ("https://gitlab.gnome.org/GNOME/evolution/issues/");
g_setenv ("E_WEB_VIEW_TEST_SOURCES", "1", FALSE);
+ g_setenv ("EVOLUTION_SOURCE_WEBKITDATADIR", EVOLUTION_SOURCE_WEBKITDATADIR, FALSE);
gtk_init (&argc, &argv);
diff --git a/src/modules/webkit-editor/CMakeLists.txt b/src/modules/webkit-editor/CMakeLists.txt
index 948442e542..5c06e67b1f 100644
--- a/src/modules/webkit-editor/CMakeLists.txt
+++ b/src/modules/webkit-editor/CMakeLists.txt
@@ -12,7 +12,6 @@ set(sources
set(extra_defines
-DEVOLUTION_WEB_EXTENSIONS_WEBKIT_EDITOR_DIR=\"${webextensionswebkiteditordir}\"
-DEVOLUTION_WEBKITDATADIR=\"${webkitdatadir}\"
- -DEVOLUTION_SOURCE_WEBKITDATADIR=\"${CMAKE_SOURCE_DIR}/data/webkit\"
)
set(extra_cflags)
set(extra_incdirs)
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 8847572bd0..c2cc0d9ec8 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -4273,6 +4273,9 @@ webkit_editor_constructor (GType type,
static gpointer web_context = NULL;
if (!web_context) {
+ #ifdef ENABLE_MAINTAINER_MODE
+ const gchar *source_webkitdatadir;
+ #endif
const gchar *schemes[] = {
"cid",
"evo-file",
@@ -4288,7 +4291,9 @@ webkit_editor_constructor (GType type,
webkit_web_context_set_sandbox_enabled (web_context, TRUE);
webkit_web_context_add_path_to_sandbox (web_context, EVOLUTION_WEBKITDATADIR,
TRUE);
#ifdef ENABLE_MAINTAINER_MODE
- webkit_web_context_add_path_to_sandbox (web_context,
EVOLUTION_SOURCE_WEBKITDATADIR, TRUE);
+ source_webkitdatadir = g_getenv ("EVOLUTION_SOURCE_WEBKITDATADIR");
+ if (source_webkitdatadir && *source_webkitdatadir)
+ webkit_web_context_add_path_to_sandbox (web_context,
source_webkitdatadir, TRUE);
#endif
g_object_add_weak_pointer (G_OBJECT (web_context), &web_context);
diff --git a/src/modules/webkit-editor/web-extension/CMakeLists.txt
b/src/modules/webkit-editor/web-extension/CMakeLists.txt
index 7ec514acc4..8220d5c5fd 100644
--- a/src/modules/webkit-editor/web-extension/CMakeLists.txt
+++ b/src/modules/webkit-editor/web-extension/CMakeLists.txt
@@ -33,7 +33,6 @@ set(sources
)
set(extra_defines
-DEVOLUTION_WEBKITDATADIR=\"${webkitdatadir}\"
- -DEVOLUTION_SOURCE_WEBKITDATADIR=\"${CMAKE_SOURCE_DIR}/data/webkit\"
)
set(extra_cflags
diff --git a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
index a4d41060f3..5b6cfb9bc5 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
@@ -99,12 +99,20 @@ load_javascript_file (JSCContext *jsc_context,
g_return_if_fail (jsc_context != NULL);
if (use_sources_js_file ()) {
- filename = g_build_filename (EVOLUTION_SOURCE_WEBKITDATADIR, js_filename, NULL);
+ const gchar *source_webkitdatadir;
- if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
- g_warning ("Cannot find '%s', using installed file '%s/%s' instead", filename,
EVOLUTION_WEBKITDATADIR, js_filename);
+ source_webkitdatadir = g_getenv ("EVOLUTION_SOURCE_WEBKITDATADIR");
- g_clear_pointer (&filename, g_free);
+ if (source_webkitdatadir && *source_webkitdatadir) {
+ filename = g_build_filename (source_webkitdatadir, js_filename, NULL);
+
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_warning ("Cannot find '%s', using installed file '%s/%s' instead",
filename, EVOLUTION_WEBKITDATADIR, js_filename);
+
+ g_clear_pointer (&filename, g_free);
+ }
+ } else {
+ g_warning ("Environment variable 'EVOLUTION_SOURCE_WEBKITDATADIR' not set or invalid
value, using installed file '%s/%s' instead", EVOLUTION_WEBKITDATADIR, js_filename);
}
}
diff --git a/src/web-extensions/CMakeLists.txt b/src/web-extensions/CMakeLists.txt
index dd699b76c0..35151503fe 100644
--- a/src/web-extensions/CMakeLists.txt
+++ b/src/web-extensions/CMakeLists.txt
@@ -19,7 +19,6 @@ add_dependencies(ewebextension
target_compile_definitions(ewebextension PRIVATE
-DG_LOG_DOMAIN=\"ewebextension\"
-DEVOLUTION_WEBKITDATADIR=\"${webkitdatadir}\"
- -DEVOLUTION_SOURCE_WEBKITDATADIR=\"${CMAKE_SOURCE_DIR}/data/webkit\"
)
target_compile_options(ewebextension PUBLIC
diff --git a/src/web-extensions/e-web-extension.c b/src/web-extensions/e-web-extension.c
index deea1bdaa7..fe0123b789 100644
--- a/src/web-extensions/e-web-extension.c
+++ b/src/web-extensions/e-web-extension.c
@@ -172,12 +172,20 @@ load_javascript_file (JSCContext *jsc_context,
g_return_if_fail (jsc_context != NULL);
if (use_sources_js_file ()) {
- filename = g_build_filename (EVOLUTION_SOURCE_WEBKITDATADIR, js_filename, NULL);
+ const gchar *source_webkitdatadir;
- if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
- g_warning ("Cannot find '%s', using installed file '%s/%s' instead", filename,
EVOLUTION_WEBKITDATADIR, js_filename);
+ source_webkitdatadir = g_getenv ("EVOLUTION_SOURCE_WEBKITDATADIR");
- g_clear_pointer (&filename, g_free);
+ if (source_webkitdatadir && *source_webkitdatadir) {
+ filename = g_build_filename (source_webkitdatadir, js_filename, NULL);
+
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_warning ("Cannot find '%s', using installed file '%s/%s' instead",
filename, EVOLUTION_WEBKITDATADIR, js_filename);
+
+ g_clear_pointer (&filename, g_free);
+ }
+ } else {
+ g_warning ("Environment variable 'EVOLUTION_SOURCE_WEBKITDATADIR' not set or invalid
value, using installed file '%s/%s' instead", EVOLUTION_WEBKITDATADIR, js_filename);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]