shakeyo / qlcolorcode

Automatically exported from code.google.com/p/qlcolorcode
0 stars 0 forks source link

' in file name causes preview colorize.sh to fail #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
*** NOTE: Do not report errors in syntax highlighting unless they are for
the following languages: C, Objective-C, or OCaml.  Report highlighting
bugs in other languages to http://www.andre-simon.de/mail.html ***

What steps will reproduce the problem?
1. Add ' to the name of a supported file
2. Attempt to preview.

What is the expected output? What do you see instead?
QLColorCode should produce a preview of the file instead a generic icon 
appears. 

What version of the product are you using? 2.0.1 On what operating system? 
10.6.3

Please provide any additional information below.
running qlmanage -p reveals an unmatch ' error in co

The following patch corrects this issue by escaping single quotes in file names.

diff --git a/Common.m b/Common.m
index 70e5d8e..f98b0e4 100644
--- a/Common.m
+++ b/Common.m
@@ -84,7 +84,7 @@ NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int 
*status, int thumbnail

     NSString *cmd = [NSString stringWithFormat:
                      @"'%@/colorize.sh' '%@' '%@' %s", 
-                     rsrcEsc, rsrcEsc, targetEsc, thumbnail ? "1" : "0"];
+                     rsrcEsc, rsrcEsc, [targetEsc 
stringByReplacingOccurrencesOfString:@"'" withString:@"'\\''"], thumbnail ? "1"
     n8log(@"cmd = %@", cmd);

     output = runTask(cmd, env, status);

Original issue reported on code.google.com by reeves.87 on 19 Jun 2010 at 4:57