Potential fix for an Issue #846

This commit is contained in:
Miroslav Stampar 2014-10-07 11:49:53 +02:00
parent ddfec1c668
commit 2ab4558859

View File

@ -1520,10 +1520,10 @@ def safeStringFormat(format_, params):
if format_.count(PAYLOAD_DELIMITER) == 2: if format_.count(PAYLOAD_DELIMITER) == 2:
_ = format_.split(PAYLOAD_DELIMITER) _ = format_.split(PAYLOAD_DELIMITER)
_[1] = _[1].replace("%d", "%s") _[1] = re.sub(r"(\A|[^A-Za-z0-9])(%d)([^A-Za-z0-9]|\Z)", r"\g<1>%s\g<3>", _[1])
retVal = PAYLOAD_DELIMITER.join(_) retVal = PAYLOAD_DELIMITER.join(_)
else: else:
retVal = format_.replace("%d", "%s") retVal = re.sub(r"(\A|[^A-Za-z0-9])(%d)([^A-Za-z0-9]|\Z)", r"\g<1>%s\g<3>", format_)
if isinstance(params, basestring): if isinstance(params, basestring):
retVal = retVal.replace("%s", params, 1) retVal = retVal.replace("%s", params, 1)