Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zwordi
funkwhale
Commits
8b13c076
Verified
Commit
8b13c076
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Fixed #893: empty contentType causing client crash in some Subsonic payloads
parent
53fa8e8c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/funkwhale_api/subsonic/serializers.py
+9
-1
9 additions, 1 deletion
api/funkwhale_api/subsonic/serializers.py
api/tests/subsonic/test_serializers.py
+23
-0
23 additions, 0 deletions
api/tests/subsonic/test_serializers.py
changes/changelog.d/893.bugfix
+1
-0
1 addition, 0 deletions
changes/changelog.d/893.bugfix
with
33 additions
and
1 deletion
api/funkwhale_api/subsonic/serializers.py
+
9
−
1
View file @
8b13c076
...
@@ -5,6 +5,7 @@ from rest_framework import serializers
...
@@ -5,6 +5,7 @@ from rest_framework import serializers
from
funkwhale_api.history
import
models
as
history_models
from
funkwhale_api.history
import
models
as
history_models
from
funkwhale_api.music
import
models
as
music_models
from
funkwhale_api.music
import
models
as
music_models
from
funkwhale_api.music
import
utils
as
music_utils
def
get_artist_data
(
artist_values
):
def
get_artist_data
(
artist_values
):
...
@@ -71,7 +72,14 @@ def get_track_data(album, track, upload):
...
@@ -71,7 +72,14 @@ def get_track_data(album, track, upload):
"
artist
"
:
album
.
artist
.
name
,
"
artist
"
:
album
.
artist
.
name
,
"
track
"
:
track
.
position
or
1
,
"
track
"
:
track
.
position
or
1
,
"
discNumber
"
:
track
.
disc_number
or
1
,
"
discNumber
"
:
track
.
disc_number
or
1
,
"
contentType
"
:
upload
.
mimetype
,
# Ugly fallback to mp3 but some subsonic clients fail if the value is empty or null, and we don't always
# have the info on legacy uploads
"
contentType
"
:
upload
.
mimetype
or
(
music_utils
.
get_type_from_ext
(
upload
.
extension
)
if
upload
.
extension
else
"
audio/mpeg
"
),
"
suffix
"
:
upload
.
extension
or
""
,
"
suffix
"
:
upload
.
extension
or
""
,
"
duration
"
:
upload
.
duration
or
0
,
"
duration
"
:
upload
.
duration
or
0
,
"
created
"
:
track
.
creation_date
,
"
created
"
:
track
.
creation_date
,
...
...
This diff is collapsed.
Click to expand it.
api/tests/subsonic/test_serializers.py
+
23
−
0
View file @
8b13c076
import
pytest
from
funkwhale_api.music
import
models
as
music_models
from
funkwhale_api.music
import
models
as
music_models
from
funkwhale_api.subsonic
import
serializers
from
funkwhale_api.subsonic
import
serializers
...
@@ -61,6 +63,27 @@ def test_get_artist_serializer(factories):
...
@@ -61,6 +63,27 @@ def test_get_artist_serializer(factories):
assert
serializers
.
GetArtistSerializer
(
artist
).
data
==
expected
assert
serializers
.
GetArtistSerializer
(
artist
).
data
==
expected
@pytest.mark.parametrize
(
"
mimetype, extension, expected
"
,
[
(
"
audio/ogg
"
,
"
noop
"
,
"
audio/ogg
"
),
(
""
,
"
ogg
"
,
"
audio/ogg
"
),
(
""
,
"
mp3
"
,
"
audio/mpeg
"
),
(
""
,
""
,
"
audio/mpeg
"
),
],
)
def
test_get_track_data_content_type
(
mimetype
,
extension
,
expected
,
factories
):
upload
=
factories
[
"
music.Upload
"
]()
upload
.
mimetype
=
mimetype
upload
.
audio_file
=
"
test.{}
"
.
format
(
extension
)
data
=
serializers
.
get_track_data
(
album
=
upload
.
track
.
album
,
track
=
upload
.
track
,
upload
=
upload
)
assert
data
[
"
contentType
"
]
==
expected
def
test_get_album_serializer
(
factories
):
def
test_get_album_serializer
(
factories
):
artist
=
factories
[
"
music.Artist
"
]()
artist
=
factories
[
"
music.Artist
"
]()
album
=
factories
[
"
music.Album
"
](
artist
=
artist
)
album
=
factories
[
"
music.Album
"
](
artist
=
artist
)
...
...
This diff is collapsed.
Click to expand it.
changes/changelog.d/893.bugfix
0 → 100644
+
1
−
0
View file @
8b13c076
Fixed empty contentType causing client crash in some Subsonic payloads (#893)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment