]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
FaxClient: Quote any " in the string before passing it to server
authorAidan Van Dyk <aidan@ifax.com>
Tue, 22 Jan 2008 21:23:30 +0000 (21:23 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Tue, 22 Jan 2008 21:23:30 +0000 (21:23 +0000)
When issuing the command:
        JPARM <param> "<string value>"
We should be quoting any of the " in the string value, or it get's
interpreted strangely by the server.

libhylafax/FaxClient.c++

index 7aa0eddc8c505920ffd7145bc04891ab8da46ee0..f79ea9842bbef9f1715c2f74b298a908abcfd7c6 100644 (file)
@@ -854,12 +854,31 @@ FaxClient::setCurrentJob(const char* jobid)
 bool
 FaxClient::jobParm(const char* name, const fxStr& value)
 {
+    /*
+     * We need to quote any " marks in the string before
+     * we pass it on to the raw jobParm(... const char*)
+     */
+    if (value.next(0,'"'))
+    {
+       fxStr tmp(value);
+       int r = tmp.length();
+       while (r > 0)
+       {
+           if ( (r = tmp.nextR(r-1, '"') ) > 0 )
+               tmp.insert('\\', r-1);
+       }
+       return jobParm(name, (const char*)tmp);
+    }
     return jobParm(name, (const char*) value);
 }
 
 bool
 FaxClient::jobParm(const char* name, const char* value)
 {
+    /*
+     * if they're passing us a wrong char*, we expect
+     * them to have handled any quoting requried.
+     */
     return (command("JPARM %s \"%s\"", name, value) == COMPLETE);
 }