import CS evince-40.5-4.el9

This commit is contained in:
eabdullin 2025-09-15 11:56:46 +00:00
parent 9a43befcad
commit 2828244a8e
3 changed files with 187 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From ebab67ba6a79da19cc8ec3c704710e9fd3613619 Mon Sep 17 00:00:00 2001
From: Marek Kasik <mkasik@redhat.com>
Date: Mon, 24 Mar 2025 13:54:33 +0100
Subject: ev-window: Fix opening of linked PDFs
Allow also button-press event for opening of linked PDFs.
Improves commit e5594f96
Reproducer file in MR !724
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 947b2e7e..91037e3d 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -6496,7 +6496,9 @@ launch_action (EvWindow *ev_window, EvLinkAction *action)
uri = get_uri (filename, ev_window);
view = EV_VIEW (priv->view);
- if (!file_is_pdf (uri) || !current_event_is_type (view, GDK_BUTTON_RELEASE)) {
+ if (!file_is_pdf (uri) ||
+ !(current_event_is_type (view, GDK_BUTTON_PRESS) ||
+ current_event_is_type (view, GDK_BUTTON_RELEASE))) {
ev_window_warning_message (ev_window,
_("Security alert: this document has been prevented from opening the file “%s”"),
filename);

View File

@ -0,0 +1,148 @@
From e5594f96468bf737bb90fee92a26f20837b614d5 Mon Sep 17 00:00:00 2001
From: Nelson Benítez León <nbenitezl@gmail.com>
Date: Sun, 30 Jan 2022 21:37:07 -0400
Subject: pdf: let launch action to open pdfs from click event
Issue #1333 removed Evince ability to run any command
from pdf 'launch action', while the security concerns
brought up in #1333 were valid, the measure implemented
was maybe too drastic, as there are valid use cases
where launching a pdf is needed.
For instance, the cases described in issue #48, one of
them is the document 'Nissan Patrol Maintenance Manual'
which is comprised of several pdf files, where there is
one acting as index for the others, this index pdf file
uses the launch action to open the other pdf's.
So this commit allows to launch a file from a link
action only when:
- that file is a pdf file.
- the launch action originates from click event,
to be sure the user requested the action.
Besides, we don't just let the system execute the
file, but because it's a pdf we do it ourselves by
launching a new evince instance (or if that file was
already opened then presenting its window).
Fixes issue #48
Modified by Marek Kasik to not change API when merging this to CentOS!
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 921be7de..88d770e8 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -6636,12 +6636,106 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
return FALSE;
}
+static gchar *
+get_uri (const char *filename, EvWindow *window)
+{
+ EvWindowPrivate *priv = GET_PRIVATE (window);
+ gchar *ret;
+
+ if (g_path_is_absolute (filename)) {
+ ret = g_strdup (filename);
+ } else {
+ GFile *base_file, *file;
+ gchar *dir;
+
+ dir = g_path_get_dirname (priv->uri);
+ base_file = g_file_new_for_uri (dir);
+ file = g_file_resolve_relative_path (base_file, filename);
+ ret = g_file_get_uri (file);
+
+ g_free (dir);
+ g_object_unref (base_file);
+ g_object_unref (file);
+ }
+
+ return ret;
+}
+
+static gboolean
+file_is_pdf (const char *uri)
+{
+ GFile *file;
+ GFileInfo *file_info;
+ gboolean ret = FALSE;
+
+ file = g_file_new_for_uri (uri);
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (file_info != NULL) {
+ const gchar *content_type;
+ content_type = g_file_info_get_content_type (file_info);
+ if (content_type) {
+ gchar *mime_type;
+ mime_type = g_content_type_get_mime_type (content_type);
+ if (g_ascii_strcasecmp (mime_type, "application/pdf") == 0)
+ ret = TRUE;
+ g_free (mime_type);
+ }
+ g_object_unref (file_info);
+ }
+ g_object_unref (file);
+
+ return ret;
+}
+
+static gboolean
+current_event_is_type (EvView *view, GdkEventType type)
+{
+ GdkEvent *event;
+ gboolean ret = FALSE;
+
+ event = gtk_get_current_event ();
+ if (event) {
+ if (event->type == type &&
+ gdk_event_get_window (event) == gtk_widget_get_window (GTK_WIDGET (view))) {
+ ret = TRUE;
+ }
+ gdk_event_free (event);
+ }
+ return ret;
+}
+
static void
-launch_action (EvWindow *window, EvLinkAction *action)
+launch_action (EvWindow *ev_window, EvLinkAction *action)
{
- ev_window_warning_message (window,
- _("Security alert: this document has been prevented from opening the file “%s”"),
- ev_link_action_get_filename (action));
+ EvView *view;
+ EvWindowPrivate *priv = GET_PRIVATE (ev_window);
+ const char *filename = ev_link_action_get_filename (action);
+ gchar *uri;
+
+ if (filename == NULL)
+ return;
+
+ uri = get_uri (filename, ev_window);
+ view = EV_VIEW (priv->view);
+
+ if (!file_is_pdf (uri) || !current_event_is_type (view, GDK_BUTTON_RELEASE)) {
+ ev_window_warning_message (ev_window,
+ _("Security alert: this document has been prevented from opening the file “%s”"),
+ filename);
+ g_free (uri);
+ return;
+ }
+ /* We are asked to open a PDF file, from a click event, proceed with that - Issue #48
+ * This spawns new Evince process or if already opened presents its window */
+ ev_application_open_uri_at_dest (EV_APP, uri,
+ gtk_window_get_screen (GTK_WINDOW (ev_window)),
+ ev_link_action_get_dest (action),
+ priv->window_mode, NULL,
+ gtk_get_current_event_time ());
+ g_free (uri);
+
}
static void

View File

@ -4,7 +4,7 @@
Name: evince
Version: 40.5
Release: 2%{?dist}
Release: 4%{?dist}
Summary: Document viewer
License: GPLv2+ and GPLv3+ and LGPLv2+ and MIT and Afmparse
@ -17,6 +17,10 @@ Patch1: evince-40.1-covscan.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2006768
Patch2: evince-40.4-quit-shortcut.patch
# https://issues.redhat.com/browse/RHEL-84038
Patch3: evince-40.5-launch-pdfs.patch
Patch4: evince-40.5-launch-event.patch
BuildRequires: gcc-c++
BuildRequires: gcc
BuildRequires: gettext-devel
@ -269,6 +273,14 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/org.gnome.Evince-p
%{_mandir}/man1/evince-previewer.1*
%changelog
* Fri May 30 2025 Marek Kasik <mkasik@redhat.com> - 40.5-4
- Fix a leak
- Resolves: RHEL-84038
* Tue May 20 2025 Marek Kasik <mkasik@redhat.com> - 40.5-3
- Allow launch action to open PDFs
- Resolves: RHEL-84038
* Tue May 24 2022 Marek Kasik <mkasik@redhat.com> - 40.5-2
- Fix requirements of evince-nautilus
- Required by CI