]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #4269 and avoid crash with gzipped file
authorEnrico Forestieri <forenr@lyx.org>
Sat, 5 Jan 2019 18:17:37 +0000 (19:17 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 19 Mar 2019 20:27:35 +0000 (21:27 +0100)
Call gunzip with quoted filenames as they may contain spaces or
other special characters.

In computing the length of the extension, the code does not account
for the prefix "unzipped_", which is added when the zipped filename
does not have one of the extensions "gz", "z", "Z", or "svgz", and
thus the used index is out of bounds. See also this thread:
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg207360.html

(cherry picked from commit 69726b832b4ed1859d5c9e753c4437c98f5f2966)
(cherry picked from commit 7296e0e6ba8bcd343fb3cdb78c8590fd0864d469)

src/insets/InsetGraphics.cpp
status.23x

index c1d9822b9358a78765f43c2ee4a1f79a84da2e22..3e4d423c87e77d529ccd990616c1f7a09149285d 100644 (file)
@@ -586,8 +586,14 @@ copyToDirIfNeeded(DocFileName const & file, string const & dir)
                // extension removed, because base.eps and base.eps.gz may
                // have different content but would get the same mangled
                // name in this case.
+               // Also take into account that if the name of the zipped file
+               // has no zip extension then the name of the unzipped one is
+               // prefixed by "unzipped_".
                string const base = removeExtension(file.unzippedFileName());
-               string::size_type const ext_len = file_in.length() - base.length();
+               string::size_type const prefix_len =
+                       prefixIs(onlyFileName(base), "unzipped_") ? 9 : 0;
+               string::size_type const ext_len =
+                       file_in.length() + prefix_len - base.length();
                mangled[mangled.length() - ext_len] = '.';
        }
        FileName const file_out(makeAbsPath(mangled, dir));
index 487d9f0414b2107601dba66d0e998d075efd2a27..b55dd8ddfd871a36fad187a26b105c6cc68f7444 100644 (file)
@@ -161,6 +161,9 @@ What's new
 
 - Fix crash when disabling math preview (bug 11498).
 
+- Quote filenames when calling gunzip and avoid a crash when the filename
+  of a compressed file does not end with a proper extension (bug 4269).
+
 
 
 * INTERNALS