From Lee:
| commit
91d837f7f0f4a6bff9a9c08b81dddc4eee3714c6
| Author: faxguy <faxguy@
5505949e-d877-4686-9e03-
c53b7a51b376>
| Date: Fri Nov 24 13:27:42 2006 +0000
|
| Getting a double-quote in a Caller*ID value causes problems.
|
| Furthermore, it poses a risk for Caller*ID doing mischevious things.
|
| So I'm changing the quote/enquote to ticks instead of double-quotes and then
| parsing through all quoted strings and coping with any ticks that appear.
|
|
| git-svn-id: https://svn.code.sf.net/p/hylafax/HylaFAX+@1503
5505949e-d877-4686-9e03-
c53b7a51b376
(void) Sys::close(fd);
}
-const fxStr faxApp::quote = " \"";
-const fxStr faxApp::enquote = "\"";
+const fxStr faxApp::quote = " \'";
+const fxStr faxApp::enquote = "\'";
+
+fxStr
+faxApp::quoted(const fxStr& s)
+{
+ fxStr q;
+ for (u_int i = 0; i < s.length(); i++) {
+ if (s[i] == '\'') q.append("\'\\\'");
+ q.append(s[i]);
+ }
+ return (q);
+}
/*
* Run the specified shell command. If changeIDs is
static const fxStr quote;
static const fxStr enquote;
+ fxStr quoted(const fxStr& s);
static bool runCmd(const char* cmd, bool changeIDs = false, IOHandler* waiter = NULL);
};
rejectCall = false;
for (u_int i = 0; i < callid.size(); i++)
- callid_formatted.append(quote | callid.id(i) | enquote);
+ callid_formatted.append(quote | quoted(callid.id(i)) | enquote);
if (callid_formatted.length())
traceProtocol("CallID:%s", (const char*) callid_formatted);
if (dynamicConfig.length()) {
- fxStr cmd(dynamicConfig | quote | getModemDevice() | enquote | callid_formatted);
+ fxStr cmd(dynamicConfig | quote | quoted(getModemDevice()) | enquote | callid_formatted);
traceServer("DynamicConfig: %s", (const char*)cmd);
fxStr localid = "";
int pipefd[2], status;
fxStr callid_formatted;
for (u_int i = 0; i < ri.callid.size(); i++) {
- callid_formatted.append(quote | ri.callid.id(i) | enquote);
+ callid_formatted.append(quote | quoted(ri.callid.id(i)) | enquote);
}
// hand to delivery/notification command
fxStr cmd(faxRcvdCmd
- | quote | ri.qfile | enquote
- | quote | getModemDeviceID() | enquote
- | quote | ri.commid | enquote
- | quote | ri.reason | enquote
+ | quote | quoted(ri.qfile) | enquote
+ | quote | quoted(getModemDeviceID()) | enquote
+ | quote | quoted(ri.commid) | enquote
+ | quote | quoted(ri.reason) | enquote
| callid_formatted);
traceServer("RECV FAX: %s", (const char*) cmd);
setProcessPriority(BASE); // lower priority
{
// hand the archiving task off to the archiving command
fxStr cmd("bin/archive"
- | quote | req.jobid | enquote
+ | quote | quoted(req.jobid) | enquote
);
runCmd(cmd, true);
}
fxStr dev(idToDev(modem.getDeviceID()));
logError("MODEM %s appears to be wedged", (const char*)dev);
fxStr cmd(wedgedCmd
- | quote | modem.getDeviceID() | enquote
- | quote | dev | enquote
+ | quote | quoted(modem.getDeviceID()) | enquote
+ | quote | quoted(dev) | enquote
);
traceServer("MODEM WEDGED: %s", (const char*) cmd);
runCmd(cmd, true, this);
faxQueueApp::notifySender(Job& job, JobStatus why, const char* duration)
{
fxStr cmd(notifyCmd
- | quote | job.file | enquote
- | quote | Job::jobStatusName(why) | enquote
- | quote | duration | enquote
+ | quote | quoted(job.file) | enquote
+ | quote | quoted(Job::jobStatusName(why)) | enquote
+ | quote | quoted(duration) | enquote
);
if (why == Job::requeued) {
/*
// hand to delivery/notification command
fxStr cmd(pollRcvdCmd
- | quote | req.mailaddr | enquote
- | quote | ri.qfile | enquote
- | quote | getModemDeviceID() | enquote
- | quote | ai.commid | enquote
- | quote | ri.reason | enquote
+ | quote | quoted(req.mailaddr) | enquote
+ | quote | quoted(ri.qfile) | enquote
+ | quote | quoted(getModemDeviceID()) | enquote
+ | quote | quoted(ai.commid) | enquote
+ | quote | quoted(ri.reason) | enquote
);
traceServer("RECV POLL: %s", (const char*) cmd);
setProcessPriority(BASE); // lower priority