Force quoted string to ascii
If setting variables to non-ascii values (such as reading data from a database) your script will fail due to UnicodeEncodeError. My forcing the encoding of the string at the 'quote' to ascii and ignoring non-ascii chars, we are able to prevent abnormal script exits due to quoted string chars.master
parent
debdd61443
commit
cef87f4241
|
@ -113,7 +113,7 @@ class AGI:
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
|
|
||||||
def _quote(self, string):
|
def _quote(self, string):
|
||||||
return ''.join(['"', str(string), '"'])
|
return ''.join(['"', string.encode('ascii', 'ignore'), '"'])
|
||||||
|
|
||||||
def _handle_sighup(self, signum, frame):
|
def _handle_sighup(self, signum, frame):
|
||||||
"""Handle the SIGHUP signal"""
|
"""Handle the SIGHUP signal"""
|
||||||
|
|
Loading…
Reference in New Issue