After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772188 - Attached (text) files open with different name
Attached (text) files open with different name
Status: RESOLVED OBSOLETE
Product: evince
Classification: Core
Component: pdf annotations
3.14.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 773098 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-09-29 14:04 UTC by Denis Bitouzé
Modified: 2018-05-22 16:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test.pdf file corresponding to the test.tex file of this bug report (13.18 KB, text/pdf)
2016-09-29 14:04 UTC, Denis Bitouzé
  Details
attachments: Save attachment files in temporary XXXXXX subdirectory (1.89 KB, patch)
2016-10-17 14:54 UTC, Felipe Borges
none Details | Review

Description Denis Bitouzé 2016-09-29 14:04:44 UTC
Created attachment 336522 [details]
test.pdf file corresponding to the test.tex file of this bug report

Context: Linux Mageia5, Evince 3.14.2.

Consider the following `test.tex' to be compiled with `pdflatex':

--8<---------------cut here---------------start------------->8---
\begin{filecontents*}{foo.tex}
\documentclass{article}
\begin{document}
Foo.
\end{document}
\end{filecontents*}
%
\documentclass{article}
\usepackage{xcolor}
\usepackage[color=black]{attachfile2}
\begin{document}
\textattachfile{foo.tex}{Link to `foo.tex'}.
\end{document}
--8<---------------cut here---------------end--------------->8---

When open in Evince, the resulting PDF file contains the link "Link to `foo.tex'" that is supposed to open `foo.tex'. But clicking on it will open `foo.tex.xxx' instead, where `xxx' is a random string. The open file has the same content as `foo.tex' but, because of its strange extension, is not open as a `.tex' file by the underlying text editor.

Notice that Adobe Reader opens this file with the same name.
Comment 1 Germán Poo-Caamaño 2016-09-29 14:27:43 UTC
This occurs because of the mechanism to create a temporary file, which uses such template.

https://git.gnome.org/browse/evince/tree/shell/ev-sidebar-attachments.c#n426
Comment 2 Denis Bitouzé 2016-09-29 14:50:58 UTC
Is there is a specific reason for that?
Comment 3 José Aliste 2016-09-29 14:59:57 UTC
In Unix, you always need a XXXXXX in the template which get replaces with random chars ensuring the file does not exist (for temp files). However, this template could be at the begining of the filename, like  XXXXXX.foo.tex or maybe even foo.XXXXXX.tex. Any of these two would not change the extension of the file.
Comment 4 Germán Poo-Caamaño 2016-09-29 15:08:04 UTC
José,

That still would not present the file name 'as is'. The attached file is already stored in evince temporary directory, so I think evince tries to avoid some sort of attack that overwrites a file or something like that.

A different solution would be to store the file in a subdirectory XXXXXX, and keeping the file name as is.
Comment 5 José Aliste 2016-09-29 15:14:23 UTC
AFAIK, the Glib API for making temp files requires the XXXXXX template...
Comment 6 Denis Bitouzé 2016-09-30 18:02:25 UTC
> That still would not present the file name 'as is'. The attached file is already stored in evince temporary directory, so I think evince tries to avoid some sort of attack that overwrites a file or something like that.

This way of doing: file stored in evince temporary directory and named 'as is', would be the best solution IMHO.
Comment 7 Germán Poo-Caamaño 2016-10-17 13:16:25 UTC
*** Bug 773098 has been marked as a duplicate of this bug. ***
Comment 8 Felipe Borges 2016-10-17 14:54:08 UTC
Created attachment 337862 [details] [review]
attachments: Save attachment files in temporary XXXXXX subdirectory

In order to present the file name "as is", it makes evince store
its temporary attachment inside a XXXXXX subdirectory instead of
the previous approach of concatenating XXXXXX to the file name.
Comment 9 jvromans 2016-10-17 15:04:59 UTC
Isn't the whole idea behind temp directories with unique names (g_dir_make_tmp()) to allow arbitrary collections of files with specified names?
Comment 10 José Aliste 2016-10-17 15:17:48 UTC
(In reply to jvromans from comment #9)
> Isn't the whole idea behind temp directories with unique names
> (g_dir_make_tmp()) to allow arbitrary collections of files with specified
> names?

You are right... this part of the code is old, so probably it existed before g_dir_make_tmp was added to GLIB. Since we are requiring Glib 2.36, we probably could update the code to use this func.
Comment 11 GNOME Infrastructure Team 2018-05-22 16:47:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/evince/issues/711.