Don't redact empty string...

This commit is contained in:
Alexandre Aubin 2021-02-25 16:44:55 +01:00
parent 2402a1db39
commit 88b414c8f3

View file

@ -376,7 +376,11 @@ class RedactingFormatter(Formatter):
msg = super(RedactingFormatter, self).format(record) msg = super(RedactingFormatter, self).format(record)
self.identify_data_to_redact(msg) self.identify_data_to_redact(msg)
for data in self.data_to_redact: for data in self.data_to_redact:
msg = msg.replace(data, "**********") # we check that data is not empty string,
# otherwise this may lead to super epic stuff
# (try to run "foo".replace("", "bar"))
if data:
msg = msg.replace(data, "**********")
return msg return msg
def identify_data_to_redact(self, record): def identify_data_to_redact(self, record):