Skip to content

Commit

Permalink
Remove old regex pattern from CensoredFormatter
Browse files Browse the repository at this point in the history
Newznab used to be a long string, and didn't have actual config sections, but that's changed now.
So now when newznab/torznab providers and loaded, the API key gets added to the censored items list.

The other reason for removing this is because the pattern isn't very accurate and can cause issues with logs (noticed this with a log from `tornado`)
  • Loading branch information
sharkykh committed May 20, 2019
1 parent eab2f7b commit 3045c78
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions medusa/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,6 @@ class CensoredFormatter(logging.Formatter, object):

absurd_re = re.compile(r'[\d\w]')

# Needed because Newznab apikey isn't stored as key=value in a section.
apikey_re = re.compile(r'(?P<before>[&?]r|[&?]apikey|[&?]api_key)(?:=|%3D)([^&]*)(?P<after>[&\w]?)', re.IGNORECASE)

def __init__(self, fmt=None, datefmt=None, encoding='utf-8'):
"""Constructor."""
super(CensoredFormatter, self).__init__(fmt, datefmt)
Expand Down Expand Up @@ -615,8 +612,6 @@ def format(self, record):
for item in censored:
msg = msg.replace(item, '**********') # must not give any hint about the length

msg = self.apikey_re.sub(r'\g<before>=**********\g<after>', msg)

level = record.levelno
if level in (WARNING, ERROR):
logline = LogLine.from_line(msg)
Expand Down

0 comments on commit 3045c78

Please sign in to comment.