RE: Parameters with single and double quotes
"Shprentz, Joel [C] " <[email protected]> Mon, 16 Jun 2003 13:33:59 -0400
| Newsgroups | gmane.comp.sysutils.ark.devel |
|---|---|
| Message-ID | <068CC65B1509FA4D89CB2E7509C5E7B99A209D@CLUWSH04.gold.rtgold.nima.mil> |
Will P wrote:
> Joel S writes:
>
> > It appears that the expandParams method of ArkRunnable in
> > ARK/arkbase/ark/thing.py calls the metaQuote function in
> > ARK/arkbase/ark/utils.py, which tries to handle quotes and
> > other special characters. When a string contains single
> > quotes, metaQuote wraps the string in double quotes, but
> > does not escape any embedded double quotes. I think this
> > could be fixed by adding another string.replace around line
> > 980 in utils.py (and renumbering the subsequent intermediate
> > strings):
> >
> > # use a double-quote; quote all the weird chars:
> > str1 = string.replace(str ,'\\','\\\\')
> > str2 = string.replace(str1,'$', '\\$')
> > + str3 = string.replace(str2,'"', '\\"')
>
> Could you let us know how you get along with a change like that?
> I'll snoop around myself, meanwhile...
I tested the change today with shell and Perl code methods. With the change
in place, I succeeded in configuring and compiling Postfix. This diff shows
my revisions:
Index: ARK/arkbase/ark/utils.py
===================================================================
RCS file: /d/cvs/arusha/arusha/ARK/arkbase/ark/utils.py,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 utils.py
--- ARK/arkbase/ark/utils.py 31 Mar 2003 18:04:42 -0000 1.1.1.3
+++ ARK/arkbase/ark/utils.py 16 Jun 2003 15:29:58 -0000
@@ -980,14 +980,15 @@
# use a double-quote; quote all the weird chars:
str1 = string.replace(str ,'\\','\\\\')
str2 = string.replace(str1,'$', '\\$')
+ str3 = string.replace(str2,'"', '\\"')
if lang == 'perl':
- str3 = string.replace(str2,'@', '\\@')
- str4 = string.replace(str2,'%', '\\%')
+ str4 = string.replace(str3,'@', '\\@')
+ str5 = string.replace(str4,'%', '\\%')
else:
- str3 = string.replace(str2,'`', '\\`')
- str4 = str3
+ str4 = string.replace(str3,'`', '\\`')
+ str5 = str4
- return '"%s"' % str4
+ return '"%s"' % str5
# --------------------------------------------------------
def hashToTupleList(table):
-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5