On Saturday, April 21, 2012 12:57:09 PM Fabio D'Urso wrote:
> On Thursday, April 19, 2012 09:44:41 PM Ihar `Philips` Filipau wrote:
> > On 4/19/12, Ihar `Philips` Filipau <[email protected]> wrote:
> > > Here is a patch which extends shell escape to cover: device name,
> > > output file name, ps file name. Win32 part was /tested/ on *nix with
> > > my eyes. And as it turned out (live and learn) cmd.exe has a command
> > > separator - &, accidentally a valid file name character - and it too
> > > has to be escaped. Guess what's escape character? 3... 2... 1... Wrong
> > > - it's '^', which itself has to be escaped too.
> > > 
> > > Have fun.
> 
> The Unix part seems to be ok, I still have a doubt about the win32 part:
>  pdftohtml -c -dev """ | calc | echo """ file.pdf
>
> [...]
> But I don't have a machine to test it at hand.

Just tested it. It still opens the calculator.

It seems that doubling doublequotes is the proper way to escape doublequotes:
From http://technet.microsoft.com/en-us/library/cc723564.aspx:
 < If a double-quoted argument itself contains a double quote character,
 the double quote must be doubled. For example, enter "Quoted" Argument
 as """Quoted"" Argument". >

According to the same document, characters & | ( ) < > ^ shouldn't be escaped 
if they are already between doublequotes.

I'm attaching a patch on top of Ihar Philips Filipau's one that fixes the 
above issues (tested on win32).

Fabio
From 899904fd589b216a6634e2c7d377098901c29fb6 Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <[email protected]>
Date: Mon, 23 Apr 2012 16:47:54 +0200
Subject: [PATCH] pdftohtml: Fix in shellEscape (win32 only)

---
 utils/pdftohtml.cc |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc
index 7b845d6..78aba3b 100644
--- a/utils/pdftohtml.cc
+++ b/utils/pdftohtml.cc
@@ -547,12 +547,9 @@ static GooString* shellEscape(const char *p)
   out->append('"');
   while (*p) {
     switch(*p) {
-    case '&':
-    case '^':
-      // ampersand is a command separator and has to be escaped with '^'
-      // same with the '^' itself
-      out->append( '^' );
-      out->append( *p );
+    case '"':
+      // Double doublequotes
+      out->append("\"\"", 2);
       break;
     default:
       out->append( *p );
-- 
1.7.6.5

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to