Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marcin Mikołajczak
funkwhale
Commits
7c473488
Verified
Commit
7c473488
authored
Jun 05, 2018
by
Eliot Berriot
Browse files
Fix #267: Do not crash when tag contains multiple uuids with a / separator
parent
a16bd2a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/metadata.py
View file @
7c473488
...
...
@@ -91,10 +91,23 @@ def convert_track_number(v):
pass
class
FirstUUIDField
(
forms
.
UUIDField
):
def
to_python
(
self
,
value
):
try
:
# sometimes, Picard leaves to uuids in the field, separated
# by a slash
value
=
value
.
split
(
'/'
)[
0
]
except
(
AttributeError
,
IndexError
,
TypeError
):
pass
return
super
().
to_python
(
value
)
VALIDATION
=
{
'musicbrainz_artistid'
:
forms
.
UUIDField
(),
'musicbrainz_albumid'
:
forms
.
UUIDField
(),
'musicbrainz_recordingid'
:
forms
.
UUIDField
(),
'musicbrainz_artistid'
:
First
UUIDField
(),
'musicbrainz_albumid'
:
First
UUIDField
(),
'musicbrainz_recordingid'
:
First
UUIDField
(),
}
CONF
=
{
...
...
api/tests/music/test_metadata.py
View file @
7c473488
...
...
@@ -95,3 +95,17 @@ def test_can_get_metadata_from_flac_file_not_crash_if_empty():
with
pytest
.
raises
(
metadata
.
TagNotFound
):
data
.
get
(
'test'
)
@
pytest
.
mark
.
parametrize
(
'field_name'
,
[
'musicbrainz_artistid'
,
'musicbrainz_albumid'
,
'musicbrainz_recordingid'
,
])
def
test_mbid_clean_keeps_only_first
(
field_name
):
u1
=
str
(
uuid
.
uuid4
())
u2
=
str
(
uuid
.
uuid4
())
field
=
metadata
.
VALIDATION
[
field_name
]
result
=
field
.
to_python
(
'/'
.
join
([
u1
,
u2
]))
assert
str
(
result
)
==
u1
changes/changelog.d/267.bugfix
0 → 100644
View file @
7c473488
Do not crash when tag contains multiple uuids with a / separator (#267)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment