XSPFParser: Use percent-encoding when loading and saving playlists

Fixes #821
This commit is contained in:
Jonas Kvinge 2022-05-13 23:32:35 +02:00
parent 18a2692dc1
commit cf9b4b1246

View File

@ -75,7 +75,7 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
switch (type) {
case QXmlStreamReader::StartElement: {
if (name == "location") {
location = reader->readElementText();
location = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
}
else if (name == "title") {
title = reader->readElementText();
@ -154,7 +154,7 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
StreamElement tracklist("trackList", &writer);
for (const Song &song : songs) {
QString filename_or_url = URLOrFilename(song.url(), dir, path_type).toUtf8();
QString filename_or_url = QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ ");
StreamElement track("track", &writer);
writer.writeTextElement("location", filename_or_url);