problems with escaped double-quotes in enscript syntax highlighting

Bug #48088 reported by Shawn McMahon
8
Affects Status Importance Assigned to Milestone
enscript (Debian)
Fix Released
Unknown
enscript (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: enscript

Take the following script:

#!/usr/bin/ksh
echo \"foo=bar\"/\"baz=quux\"
echo "and here's some other stuff"
for i in foo bar baz quux
do
  echo $i
done

...which I've also attached. In gview, those escaped double-quotes are handled properly, and syntax hightlighting works. With enscript, using either sh or ksh highlighting, the first double-quote turns on the highlighting for "this is quoted stuff", but the rest are ignored until the first unescaped double-quote is encountered.

The enscript command line was "cat enscriptbug | enscript --highlight=ksh --color -r -p enscriptbug.ps"

I hit this on Breezy yesterday and confirmed it on Dapper today.

Attached are the script, a screenshot of how gview renders it, and the output of enscript.

$ apt-cache policy enscript
enscript:
  Installed: 1.6.4-7
  Candidate: 1.6.4-7
  Version table:
 *** 1.6.4-7 0
        500 http://us.archive.ubuntu.com dapper/main Packages
        100 /var/lib/dpkg/status

Revision history for this message
Shawn McMahon (smcmahon) wrote : enscriptbug - script that demonstrates the bug

The script I wrote to reproduce the bug. (The original script in which I encountered the error contains proprietary company stuff).

Revision history for this message
Shawn McMahon (smcmahon) wrote : screenshot

A screenshot of gview highlighting the script properly.

Revision history for this message
Shawn McMahon (smcmahon) wrote : enscriptbug.ps

Output from:

cat enscriptbug | enscript --highlight=ksh --color -r -p enscriptbug.ps

Revision history for this message
Shawn McMahon (smcmahon) wrote :

This modification to ksh.st fixes it for ksh. Same thing could be done for sh.st also. I'm not sure how to create a proper patch for you, sorry. This is what's done in perl.st already.

*** enscript-1.6.4.orig/states/hl/ksh.st 2003-03-05 02:26:33.000000000 -0500
--- enscript-1.6.4.shawn/states/hl/ksh.st 2006-06-03 23:19:53.000000000 -0400
***************
*** 34,39 ****
--- 34,50 ----
      reference_face (false);
    }

+ /* Ignore escaped quote marks */
+ /\\\"/ {
+ language_print ($0);
+ }
+ /\\\'/ {
+ language_print ($0);
+ }
+ /\\\`/ {
+ language_print ($0);
+ }
+
    /* Keywords:
       (build-re '(: alias bg break continue cd command eval exec exit export
       fc fg getopts hash jobs kill let login newgrp print pwd read readonly

Revision history for this message
Shawn McMahon (smcmahon) wrote : A patch

Ok, advanced my clue quotient, here's a patch that fixes it for both ksh and sh.

I will also submit this to upstream, if I can figure out how they want them.

Revision history for this message
Shawn McMahon (smcmahon) wrote :

Emailed a link to the bug report and the patch to <email address hidden>.

Revision history for this message
Shawn McMahon (smcmahon) wrote :

Hey, since we've got a new maintainer now, any chance my patch goes in? There's more of these, and I'd be happy to track them down and submit if it'll do any good now.

Revision history for this message
Shawn McMahon (smcmahon) wrote :

Definitely still present:

$ apt-cache policy enscript
enscript:
  Installed: 1.6.4-11build1
  Candidate: 1.6.4-11build1
  Version table:
 *** 1.6.4-11build1 0
        500 http://us.archive.ubuntu.com feisty/main Packages
        100 /var/lib/dpkg/status

Revision history for this message
Shawn McMahon (smcmahon) wrote :

Debian says they may have fixed this in 1.6.4-12. I don't think they used my patch, don't have a Debian box currently to play with to be sure.

Revision history for this message
Tim Retout (diocles) wrote :

Fixed in 1.6.4-12

Changed in enscript:
status: New → Fix Released
Revision history for this message
Tim Retout (diocles) wrote :

Shawn: I did use your patch, but extended it to cover various other shells. It is also now committed upstream:
http://git.sv.gnu.org/gitweb/?p=enscript.git;a=commit;h=309191449dee4b93e2b1015665c2f3ad41f0801e

Changed in enscript:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.