Skip to content

Commit

Permalink
Remove old regex pattern from CensoredFormatter (pymedusa#6705)
Browse files Browse the repository at this point in the history
* Remove old regex pattern from `CensoredFormatter`

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`)

* Update changelog
  • Loading branch information
sharkykh authored and Thilas committed Jun 5, 2019
1 parent ff0fbdb commit 320e868
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
- Fixed download of multi episode releases without single results ([#6537](https://github.com/pymedusa/Medusa/pull/6537))
- Fixed "send to trash" option not doing anything (Python 3.6 and higher) ([#6625](https://github.com/pymedusa/Medusa/pull/6625))
- Fixed setting episodes to archived in backlog overview ([#6636](https://github.com/pymedusa/Medusa/pull/6636))
- Fixed exception in Elte-Tracker provider when no result is found ([#6680](https://github.com/pymedusa/Medusa/pull/6680))
- Fixed exception in Elite-Tracker provider when no result is found ([#6680](https://github.com/pymedusa/Medusa/pull/6680))
- Fixed exception in API v2 when an incorrect API key was provided, or none was provided ([#6703](https://github.com/pymedusa/Medusa/pull/6703))
- Removed legacy log-censoring code for Newznab providers ([#6705](https://github.com/pymedusa/Medusa/pull/6705))

## 0.3.1 (2019-03-20)

Expand Down
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 320e868

Please sign in to comment.