From b287c5f8293f8999ef9850e6d624a63e099d16af Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 4 Apr 2012 23:28:19 +0200 Subject: [PATCH] Fixed importing Html bookmarks from various browsers. - fixed one potentional crash in importing --- README.md | 4 +-- scripts/macdeploy.sh | 14 +++++---- src/lib/app/profileupdater.cpp | 15 +++++++++- src/lib/bookmarksimport/htmlimporter.cpp | 36 ++++++++++++++++++------ 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 52d47a1e3..f69825d99 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ QupZilla Web Browser ---------------------------------------------------------------------------------------- -Homepage: http://www.qupzilla.com -Blog: http://blog.qupzilla.com/ +Homepage: http://www.qupzilla.com +Blog: http://blog.qupzilla.com/ IRC: `#qupzilla` at `irc.freenode.net` About QupZilla diff --git a/scripts/macdeploy.sh b/scripts/macdeploy.sh index b4cf65e39..74c4c6521 100755 --- a/scripts/macdeploy.sh +++ b/scripts/macdeploy.sh @@ -1,27 +1,29 @@ #!/bin/bash COMMAND=$1 +LIBRARY_NAME="libQupZilla.1.dylib" if [ $COMMAND = "" ]; then $COMMAND="macdeployqt" fi # cd to directory with bundle -cd ../build +test -d build || cd .. +cd build # copy libQupZilla into bundle -cp libQupZilla* QupZilla.app/Contents/MacOS/QupZilla +cp $LIBRARY_NAME QupZilla.app/Contents/MacOS/ # copy all plugins into bundle test -d QupZilla.app/Contents/Resources/plugins || mkdir QupZilla.app/Contents/Resources/plugins -cp plugins/*.dylib QupZilla.app/Contents/Resources/plugins +cp plugins/*.dylib QupZilla.app/Contents/Resources/plugins/ # fix libQupZilla -install_name_tool -change libQupZilla.1.dylib @executable_path/libQupZilla.1.dylib QupZilla.app/Contents/MacOS/QupZilla +install_name_tool -change $LIBRARY_NAME @executable_path/$LIBRARY_NAME QupZilla.app/Contents/MacOS/QupZilla # fix plugins -for plugin in QupZilla.app/Contents/Resources/plugins*.dylib +for plugin in QupZilla.app/Contents/Resources/plugins/*.dylib do - install_name_tool -change libQupZilla.1.dylib @executable_path/libQupZilla.1.dylib $plugin + install_name_tool -change $LIBRARY_NAME @executable_path/$LIBRARY_NAME $plugin done # run macdeployqt diff --git a/src/lib/app/profileupdater.cpp b/src/lib/app/profileupdater.cpp index fb0d3f12c..e16bc5e50 100644 --- a/src/lib/app/profileupdater.cpp +++ b/src/lib/app/profileupdater.cpp @@ -18,10 +18,12 @@ #include "profileupdater.h" #include "qupzilla.h" #include "updater.h" +#include "globalfunctions.h" #include "mainapplication.h" #include #include +#include #include ProfileUpdater::ProfileUpdater(const QString &profilePath) @@ -111,7 +113,18 @@ void ProfileUpdater::copyDataToProfile() QDir profileDir(m_profilePath); profileDir.mkdir("certificates"); - QFile(m_profilePath + "browsedata.db").remove(); + QFile browseData(m_profilePath + "browsedata.db"); + if (browseData.exists()) { + const QString &browseDataBackup = qz_ensureUniqueFilename(m_profilePath + "browsedata-backup.db"); + const QString &settingsBackup = qz_ensureUniqueFilename(m_profilePath + "settings-backup.ini"); + browseData.copy(browseDataBackup); + QFile(m_profilePath + "settings.ini").copy(settingsBackup); + const QString &text = "Incompatible profile version has been detected. To avoid losing your profile data, they were " + "backed up in following directories:

" + browseDataBackup + "
" + settingsBackup + "
"; + QMessageBox::warning(0, "QupZilla: Incompatible profile version", text); + } + + browseData.remove(); QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db"); QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser); } diff --git a/src/lib/bookmarksimport/htmlimporter.cpp b/src/lib/bookmarksimport/htmlimporter.cpp index b9f3aad0a..2db2cde17 100644 --- a/src/lib/bookmarksimport/htmlimporter.cpp +++ b/src/lib/bookmarksimport/htmlimporter.cpp @@ -66,17 +66,33 @@ QList HtmlImporter::exportBookmarks() QString bookmarks = QString::fromUtf8(m_file.readAll()); m_file.close(); - bookmarks = bookmarks.mid(0, bookmarks.lastIndexOf("

")); - int start = bookmarks.indexOf("

", Qt::CaseInsensitive); + + // Converting tags to lower case -,- + // For some reason Qt::CaseInsensitive is not everytime insensitive :-D + + bookmarks.replace("

")); + int start = bookmarks.indexOf("

"); QStringList folders("Html Import"); while (start > 0) { QString string = bookmarks.mid(start); - int posOfFolder = string.indexOf("

", Qt::CaseInsensitive); - int posOfLink = string.indexOf("

"); + int posOfLink = string.indexOf("

HtmlImporter::exportBookmarks() if (nearest == posOfFolder) { // Next is folder - QRegExp rx("
(.*)", Qt::CaseInsensitive); + QRegExp rx("
(.*)"); rx.setMinimal(true); rx.indexIn(string); @@ -98,20 +114,22 @@ QList HtmlImporter::exportBookmarks() } else if (nearest == posOfEndFolder) { // Next is end of folder - folders.removeLast(); + if (!folders.isEmpty()) { + folders.removeLast(); + } start += posOfEndFolder + 8; } else { // Next is link - QRegExp rx("
(.*)", Qt::CaseInsensitive); + QRegExp rx("
(.*)"); rx.setMinimal(true); rx.indexIn(string); QString arguments = rx.cap(1); QString linkName = rx.cap(2); - QRegExp rx2("HREF=\"(.*)\"", Qt::CaseInsensitive); + QRegExp rx2("href=\"(.*)\""); rx2.setMinimal(true); rx2.indexIn(arguments);