[Tutor] Cgi Fieldstorage cant get quotes-Solution
Conrad Koziol
arkamir at softhome.net
Fri Jan 23 17:56:09 EST 2004
Thanks a lot Kirk Bailey for the help. Heres the final solution:
class Form_filter(Top):
def __init__(self):
super(Form_filter, self).__init__()
def filter(self):
illegal = {r'"': r'\"', r"'": r'\''}
regex = re.compile('|'.join(map(re.escape, illegal.keys())))
for item in self.dict.keys():
self.dict[item] = regex.sub(lambda match: illegal[match.group(0)],
self.dict[item])
I think my email client is going to mess it up. :(
It basically the Replacing multiple patterns in a single pass Cookbook
recipe wiht a slight modification. Self.dict is where i store my form
values.There basically the fieldstorage values put into a dictionary for
easier use.
More information about the Tutor
mailing list