diff --git a/src/Config.h b/src/Config.h index 72ba6c76..e85592af 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 282 +#define VER_LAMEXP_BUILD 283 #define VER_LAMEXP_SUFFIX Beta-3 /* diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index ee7559cf..a3c27567 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -31,9 +31,13 @@ #include #include #include +#include #include +//Un-escape XML characters +#define XML_DECODE replace("&", "&").replace("'", "'").replace(" ", " ").replace(""", "\"").replace("<", "<").replace(">", ">") + //////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////// @@ -499,49 +503,37 @@ bool FileAnalyzer::parsePlaylist_pls(QFile &data, QStringList &fileList, const Q bool FileAnalyzer::parsePlaylist_wpl(QFile &data, QStringList &fileList, const QDir &baseDir, const QDir &rootDir) { + QRegExp skipData("", Qt::CaseInsensitive); QRegExp wplEntry("<(media|ref)[^<>]*(src|href)=\"([^\"]+)\"[^<>]*>", Qt::CaseInsensitive); - QByteArray line = data.readLine(); - while(line.size() > 0) + skipData.setMinimal(true); + + QByteArray buffer = data.readAll(); + QString line = QString::fromUtf8(buffer.constData(), buffer.size()).simplified(); + buffer.clear(); + + int index = 0; + + while((index = skipData.indexIn(line)) >= 0) { - bool flag = false; - - QString temp1(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed())); - QString temp2(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed())); + line.remove(index, skipData.matchedLength()); + } - if(!flag && wplEntry.indexIn(temp1) >= 0) + int offset = 0; + + while((offset = wplEntry.indexIn(line, offset) + 1) > 0) + { + QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3).XML_DECODE.trimmed())); + filename.setCaching(false); + fixFilePath(filename, baseDir, rootDir); + + if(filename.exists()) { - QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3)).trimmed()); - filename.setCaching(false); - fixFilePath(filename, baseDir, rootDir); - - if(filename.exists()) + if(isPlaylist(filename.canonicalFilePath()) == noPlaylist) { - if(isPlaylist(filename.canonicalFilePath()) == noPlaylist) - { - fileList << filename.canonicalFilePath(); - flag = true; - } + fileList << filename.canonicalFilePath(); } } - - if(!flag && wplEntry.indexIn(temp2) >= 0) - { - QFileInfo filename(QDir::fromNativeSeparators(wplEntry.cap(3)).trimmed()); - filename.setCaching(false); - fixFilePath(filename, baseDir, rootDir); - - if(filename.exists()) - { - if(isPlaylist(filename.canonicalFilePath()) == noPlaylist) - { - fileList << filename.canonicalFilePath(); - flag = true; - } - } - } - - line = data.readLine(); } return true;