Skip to content

Commit

Permalink
web: __init__: _rep: Filter all bytes for serializer
Browse files Browse the repository at this point in the history
This commit fixes issue beetbox#2532 by filtering out any byte values
added by any other extensions and decoding them to strings for the
JSON serializer.

It does not remove any of the keys, instead opting to just convert
them.

Signed-off-by: Mark Stenglein <[email protected]>
  • Loading branch information
ocelotsloth committed May 3, 2017
1 parent 84febb1 commit 8804760
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions beetsplug/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def _rep(obj, expand=False):
else:
del out['path']

# Filter all bytes attributes and convert them to strings
isBytes = lambda key: isinstance(out[key], bytes)

for key in filter(isBytes, out):
out[key] = out[key].decode('utf-8')

# Get the size (in bytes) of the backing file. This is useful
# for the Tomahawk resolver API.
try:
Expand Down

0 comments on commit 8804760

Please sign in to comment.