]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 855: typerules handling of file names with spaces
authorAidan Van Dyk <aidan@ifax.com>
Fri, 11 May 2007 15:50:39 +0000 (15:50 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Fri, 11 May 2007 15:50:39 +0000 (15:50 +0000)
Following Lee's suggestion, we carefully quote the filenames for input and
output files.

util/TypeRules.c++

index 645a83f261cecad242d72207018bab9a7f6c65a1..1b14c3088436bda5c2daba4e44e6faa3a4b36e09 100644 (file)
@@ -69,6 +69,21 @@ static const char* opNames[] =
     { "<any>", "=", "!=", "<", "<=", ">", ">=", "&", "^", "!" };
 static const char* resultNames[] = { "tiff", "postscript", "pdf", "error" };
 
+fxStr
+quoted(const fxStr& s)
+{
+    fxStr q("'");;
+    for (u_int i = 0; i < s.length(); i++) {
+       if (s[i] == '\'')
+           q.append("'\\''");
+       else
+           q.append(s[i]);
+    }
+    q.append("'");
+    return (q);
+}
+
+
 bool
 TypeRule::match(const void* data, size_t size, bool verbose) const
 {
@@ -213,8 +228,8 @@ TypeRule::getFmtdCmd(
        if (c == '%' && i+1 < n) {
            i++;
            switch (c = cmd[i]) {
-           case 'i':   fmtd.append(input);                       continue;
-           case 'o':   fmtd.append(output);                      continue;
+           case 'i':   fmtd.append(quoted(input));               continue;
+           case 'o':   fmtd.append(quoted(output));              continue;
            case 'R':   fmtd.append(fxStr(hr, "%.2f"));           continue;
            case 'r':   fmtd.append(fxStr(hr/25.4, "%.2g"));      continue;
            case 'V':   fmtd.append(fxStr(vr, "%.2f"));           continue;