summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-08-27 16:25:40 +0200
committerYoann Lopes <yoann.lopes@digia.com>2014-09-09 18:06:56 +0200
commite26483c106cd1408b768f18f5d0edfd83c78f5bf (patch)
tree431df982733c9fd4332d71f73da3c23bb85af5e0 /src/multimedia
parent973ae5e0f60d335d1b22f9a2418fe50839d50322 (diff)
Fix URL handling in PLS parser.
Make sure relative paths are resolved to a full path. Task-number: QTBUG-40515 Change-Id: Ideb83fc3a3c4a74c84917a22e3c30162d7b6158a Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/playback/playlistfileparser.cpp51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/multimedia/playback/playlistfileparser.cpp b/src/multimedia/playback/playlistfileparser.cpp
index 1254d6131..97c551c97 100644
--- a/src/multimedia/playback/playlistfileparser.cpp
+++ b/src/multimedia/playback/playlistfileparser.cpp
@@ -59,6 +59,30 @@ public:
virtual void parseLine(int lineIndex, const QString& line, const QUrl& root) = 0;
+protected:
+ QUrl expandToFullPath(const QUrl &root, const QString &line)
+ {
+ // On Linux, backslashes are not converted to forward slashes :/
+ if (line.startsWith(QLatin1String("//")) || line.startsWith(QLatin1String("\\\\"))) {
+ // Network share paths are not resolved
+ return QUrl::fromLocalFile(line);
+ }
+
+ QUrl url(line);
+ if (url.scheme().isEmpty()) {
+ // Resolve it relative to root
+ if (root.isLocalFile())
+ return root.resolved(QUrl::fromLocalFile(line));
+ else
+ return root.resolved(url);
+ } else if (url.scheme().length() == 1) {
+ // Assume it's a drive letter for a Windows path
+ url = QUrl::fromLocalFile(line);
+ }
+
+ return url;
+ }
+
Q_SIGNALS:
void newItem(const QVariant& content);
void finished();
@@ -146,29 +170,6 @@ public:
return -1;
}
- QUrl expandToFullPath(const QUrl& root, const QString& line)
- {
- // On Linux, backslashes are not converted to forward slashes :/
- if (line.startsWith(QLatin1String("//")) || line.startsWith(QLatin1String("\\\\"))) {
- // Network share paths are not resolved
- return QUrl::fromLocalFile(line);
- }
-
- QUrl url(line);
- if (url.scheme().isEmpty()) {
- // Resolve it relative to root
- if (root.isLocalFile())
- return root.resolved(QUrl::fromLocalFile(line));
- else
- return root.resolved(url);
- } else if (url.scheme().length() == 1) {
- // Assume it's a drive letter for a Windows path
- url = QUrl::fromLocalFile(line);
- }
-
- return url;
- }
-
private:
bool m_extendedFormat;
QVariantMap m_extraInfo;
@@ -249,7 +250,7 @@ Version=2
m_readFlags |= int(flag);
}
- void parseLine(int lineIndex, const QString& line, const QUrl&)
+ void parseLine(int lineIndex, const QString &line, const QUrl &root)
{
switch (m_state) {
case Header:
@@ -260,7 +261,7 @@ Version=2
break;
case Track:
if (!containsFlag(FileRead) && line.startsWith(m_fileName)) {
- m_item[QLatin1String("url")] = getValue(lineIndex, line);
+ m_item[QLatin1String("url")] = expandToFullPath(root, getValue(lineIndex, line));
setFlag(FileRead);
} else if (!containsFlag(TitleRead) && line.startsWith(m_titleName)) {
m_item[QMediaMetaData::Title] = getValue(lineIndex, line);