1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00

Assume URLs in podcast RSS feeds are already URL encoded

This commit is contained in:
David Sansome 2012-03-15 16:36:25 +00:00
parent 9cf279f5a3
commit 56b9546744

View File

@ -102,7 +102,7 @@ void PodcastParser::ParseChannel(QXmlStreamReader* reader, Podcast* ret) const {
if (name == "title") { if (name == "title") {
ret->set_title(reader->readElementText()); ret->set_title(reader->readElementText());
} else if (name == "link" && reader->namespaceUri().isEmpty()) { } else if (name == "link" && reader->namespaceUri().isEmpty()) {
ret->set_link(QUrl(reader->readElementText())); ret->set_link(QUrl::fromEncoded(reader->readElementText().toAscii()));
} else if (name == "description") { } else if (name == "description") {
ret->set_description(reader->readElementText()); ret->set_description(reader->readElementText());
} else if (name == "owner" && reader->namespaceUri() == kItunesNamespace) { } else if (name == "owner" && reader->namespaceUri() == kItunesNamespace) {
@ -113,7 +113,7 @@ void PodcastParser::ParseChannel(QXmlStreamReader* reader, Podcast* ret) const {
ret->set_copyright(reader->readElementText()); ret->set_copyright(reader->readElementText());
} else if (name == "link" && reader->namespaceUri() == kAtomNamespace && } else if (name == "link" && reader->namespaceUri() == kAtomNamespace &&
ret->url().isEmpty() && reader->attributes().value("rel") == "self") { ret->url().isEmpty() && reader->attributes().value("rel") == "self") {
ret->set_url(QUrl(reader->readElementText())); ret->set_url(QUrl::fromEncoded(reader->readElementText().toAscii()));
} else if (name == "item") { } else if (name == "item") {
ParseItem(reader, ret); ParseItem(reader, ret);
} else { } else {
@ -138,7 +138,7 @@ void PodcastParser::ParseImage(QXmlStreamReader* reader, Podcast* ret) const {
case QXmlStreamReader::StartElement: { case QXmlStreamReader::StartElement: {
const QStringRef name = reader->name(); const QStringRef name = reader->name();
if (name == "url") { if (name == "url") {
ret->set_image_url_large(QUrl(reader->readElementText())); ret->set_image_url_large(QUrl::fromEncoded(reader->readElementText().toAscii()));
} else { } else {
Utilities::ConsumeCurrentElement(reader); Utilities::ConsumeCurrentElement(reader);
} }
@ -206,7 +206,7 @@ void PodcastParser::ParseItem(QXmlStreamReader* reader, Podcast* ret) const {
} }
} else if (name == "enclosure") { } else if (name == "enclosure") {
if (reader->attributes().value("type").toString().startsWith("audio/")) { if (reader->attributes().value("type").toString().startsWith("audio/")) {
episode.set_url(QUrl(reader->attributes().value("url").toString())); episode.set_url(QUrl::fromEncoded(reader->attributes().value("url").toString().toAscii()));
} }
Utilities::ConsumeCurrentElement(reader); Utilities::ConsumeCurrentElement(reader);
} else if (name == "author" && reader->namespaceUri() == kItunesNamespace) { } else if (name == "author" && reader->namespaceUri() == kItunesNamespace) {
@ -263,8 +263,8 @@ void PodcastParser::ParseOutline(QXmlStreamReader* reader, OpmlContainer* ret) c
Podcast podcast; Podcast podcast;
podcast.set_description(attributes.value("description").toString()); podcast.set_description(attributes.value("description").toString());
podcast.set_title(attributes.value("text").toString()); podcast.set_title(attributes.value("text").toString());
podcast.set_image_url_large(QUrl(attributes.value("imageHref").toString())); podcast.set_image_url_large(QUrl::fromEncoded(attributes.value("imageHref").toString().toAscii()));
podcast.set_url(QUrl(attributes.value("xmlUrl").toString())); podcast.set_url(QUrl::fromEncoded(attributes.value("xmlUrl").toString().toAscii()));
ret->feeds.append(podcast); ret->feeds.append(podcast);
// Consume any children and the EndElement. // Consume any children and the EndElement.