diff --git a/ChangeLog b/ChangeLog index ee19e388b..738f6b1dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,8 +54,10 @@ QtCurve theme. 8. Fix playing of some non-MP3 files external to MPD database via Cantata's simple HTTP server. - 9. Fix detection of some filetypes. -10. Prevent multiple KDE Cantata windows appearing if app is attempted to be + 9. Fix playing of files containing square brackets, etc, that are external + to MPD database via Cantata's simple HTTP server. +10. Fix detection of some filetypes. +11. Prevent multiple KDE Cantata windows appearing if app is attempted to be started repeatedly in quick succession. 0.9.1 diff --git a/http/httpserver.cpp b/http/httpserver.cpp index ee7f8dd4d..57b5a5934 100644 --- a/http/httpserver.cpp +++ b/http/httpserver.cpp @@ -147,7 +147,6 @@ QByteArray HttpServer::encodeUrl(const Song &s) const QByteArray HttpServer::encodeUrl(const QString &file) const { Song s=Tags::read(file); - s.fillEmptyFields(); s.file=file; return encodeUrl(s); } diff --git a/http/httpsocket.cpp b/http/httpsocket.cpp index 68ddb291e..5cd2a9a1b 100644 --- a/http/httpsocket.cpp +++ b/http/httpsocket.cpp @@ -178,6 +178,38 @@ void HttpSocket::incomingConnection(int socket) s->setSocketDescriptor(socket); } +int getSep(const QByteArray &a, int pos) +{ + for (int i=pos+1; i split(const QByteArray &a) +{ + QList rv; + int lastPos=-1; + for (;;) { + int pos=getSep(a, lastPos); + + if (pos==(lastPos+1)) { + lastPos++; + } else if (pos>-1) { + lastPos++; + rv.append(a.mid(lastPos, pos-lastPos)); + lastPos=pos; + } else { + lastPos++; + rv.append(a.mid(lastPos)); + break; + } + } + return rv; +} + void HttpSocket::readClient() { if (terminated) { @@ -186,11 +218,11 @@ void HttpSocket::readClient() QTcpSocket *socket = (QTcpSocket*)sender(); if (socket->canReadLine()) { - QString line=socket->readLine(); - QStringList tokens = line.split(QRegExp("[ \r\n][ \r\n]*")); - if (QLatin1String("GET")==tokens[0]) { - QUrl url(tokens[1]); + QList tokens = split(socket->readLine()); // QRegExp("[ \r\n][ \r\n]*")); + if (tokens.length()>=2 && "GET"==tokens[0]) { + QUrl url(QUrl::fromPercentEncoding(tokens[1])); bool ok=false; + if (url.hasQueryItem("cantata")) { QFile f(url.path()); diff --git a/models/playqueuemodel.cpp b/models/playqueuemodel.cpp index 9c3b31677..94b9c7d78 100644 --- a/models/playqueuemodel.cpp +++ b/models/playqueuemodel.cpp @@ -55,13 +55,6 @@ static QStringList reverseList(const QStringList &orig) return rev; } -#ifdef TAGLIB_FOUND -static inline QString unencodeUrl(QString u) -{ - return QUrl(u).path(); -} -#endif - const QLatin1String PlayQueueModel::constMoveMimeType("cantata/move"); const QLatin1String PlayQueueModel::constFileNameMimeType("cantata/filename"); const QLatin1String PlayQueueModel::constUriMimeType("text/uri-list"); @@ -506,16 +499,16 @@ bool PlayQueueModel::dropMimeData(const QMimeData *data, bool allowLocal=haveHttp || mpdLocal; foreach (QString u, orig) { - if (u.startsWith("http://")) { + if (u.startsWith(QLatin1String("http://"))) { useable.append(u); - } else if (allowLocal && (u.startsWith('/') || u.startsWith("file:/"))) { - if (u.startsWith("file:/")) { + } else if (allowLocal && (u.startsWith('/') || u.startsWith(QLatin1String("file:/")))) { + if (u.startsWith(QLatin1String("file:/"))) { u=u.mid(7); } if (alwaysUseHttp || !mpdLocal) { - useable.append(HttpServer::self()->encodeUrl(unencodeUrl(u))); + useable.append(HttpServer::self()->encodeUrl(QUrl::fromPercentEncoding(u.toUtf8()))); } else { - useable.append(QLatin1String("file://")+unencodeUrl(u)); + useable.append((u.startsWith(QLatin1String("file:/")) ? QString() : QLatin1String("file://"))+QUrl::fromPercentEncoding(u.toUtf8())); } } }