GNU bug report logs - #13679
24.2.93; doc-view-mode cannot handle PDFs whose filename contains a percentage sign

Previous Next

Package: emacs;

Reported by: Elias Pipping <pipping <at> lavabit.com>

Date: Sun, 10 Feb 2013 18:04:02 UTC

Severity: normal

Found in version 24.2.93

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13679 in the body.
You can then email your comments to 13679 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13679; Package emacs. (Sun, 10 Feb 2013 18:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Elias Pipping <pipping <at> lavabit.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 10 Feb 2013 18:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Elias Pipping <pipping <at> lavabit.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2.93;
	doc-view-mode cannot handle PDFs whose filename contains a percentage
	sign
Date: Sun, 10 Feb 2013 18:59:05 +0100
[Message part 1 (text/plain, inline)]
Hi,

doc-view-mode currently calls either ghostscript or mupdf's mudraw to
render PDFs to PNG images. Both tools interpret a percentage sign in
the name of the target file as a format instruction. Since doc-view's
cache directory is named after the input PDF, whose name can contain
percentage signs, it, too, can contain percentage signs.

As a result, doc-view mode cannot currently handle PDF files whose name
contains a percentage sign. I've attached the simplest fix I could think
of.


Best regards,

Elias Pipping

[0001-Escape-percentage-signs.patch (text/x-patch, inline)]
From 2c35f04fc1191878b01b4ab07821e20fdc461511 Mon Sep 17 00:00:00 2001
From: Elias Pipping <pipping <at> exherbo.org>
Date: Sun, 10 Feb 2013 18:51:10 +0100
Subject: [PATCH] Escape percentage signs

---
 lisp/doc-view.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index e7d1ebc..18e17bd 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -675,6 +675,9 @@ at the top edge of the page moves to the previous page."
 	 (format "Unable to use temporary directory %s: %s"
 		 dir (mapconcat 'identity (cdr error) " "))))))))
 
+(defun doc-view-escape-percentage-sign (str)
+  (replace-regexp-in-string "%" "_" str))
+
 (defun doc-view-current-cache-dir ()
   "Return the directory where the png files of the current doc should be saved.
 It's a subdirectory of `doc-view-cache-directory'."
@@ -686,7 +689,8 @@ It's a subdirectory of `doc-view-cache-directory'."
     (setq doc-view-current-cache-dir
 	  (file-name-as-directory
 	   (expand-file-name
-	    (concat (file-name-nondirectory doc-view-buffer-file-name)
+	    (concat (doc-view-escape-percentage-sign
+                     (file-name-nondirectory doc-view-buffer-file-name))
 		    "-"
 		    (let ((file doc-view-buffer-file-name))
 		      (with-temp-buffer
-- 
1.8.1.2


Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 11 Feb 2013 19:32:01 GMT) Full text and rfc822 format available.

Notification sent to Elias Pipping <pipping <at> lavabit.com>:
bug acknowledged by developer. (Mon, 11 Feb 2013 19:32:01 GMT) Full text and rfc822 format available.

Message #10 received at 13679-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Elias Pipping <pipping <at> lavabit.com>
Cc: 13679-done <at> debbugs.gnu.org
Subject: Re: bug#13679: 24.2.93;
	doc-view-mode cannot handle PDFs whose filename contains a percentage
	sign
Date: Mon, 11 Feb 2013 14:30:40 -0500
> I've attached the simplest fix I could think of.

Looks good, thank you, installed in a slightly simpler form (using
subst-char-in-string and without defining a separate function for it).


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 Mar 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.