mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
Fixed importing Html bookmarks from various browsers.
- fixed one potentional crash in importing
This commit is contained in:
parent
f94e69d557
commit
b287c5f829
|
@ -1,8 +1,8 @@
|
||||||
QupZilla Web Browser
|
QupZilla Web Browser
|
||||||
----------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Homepage: http://www.qupzilla.com
|
Homepage: http://www.qupzilla.com
|
||||||
Blog: http://blog.qupzilla.com/
|
Blog: http://blog.qupzilla.com/
|
||||||
IRC: `#qupzilla` at `irc.freenode.net`
|
IRC: `#qupzilla` at `irc.freenode.net`
|
||||||
|
|
||||||
About QupZilla
|
About QupZilla
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
COMMAND=$1
|
COMMAND=$1
|
||||||
|
LIBRARY_NAME="libQupZilla.1.dylib"
|
||||||
|
|
||||||
if [ $COMMAND = "" ]; then
|
if [ $COMMAND = "" ]; then
|
||||||
$COMMAND="macdeployqt"
|
$COMMAND="macdeployqt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cd to directory with bundle
|
# cd to directory with bundle
|
||||||
cd ../build
|
test -d build || cd ..
|
||||||
|
cd build
|
||||||
|
|
||||||
# copy libQupZilla into bundle
|
# copy libQupZilla into bundle
|
||||||
cp libQupZilla* QupZilla.app/Contents/MacOS/QupZilla
|
cp $LIBRARY_NAME QupZilla.app/Contents/MacOS/
|
||||||
|
|
||||||
# copy all plugins into bundle
|
# copy all plugins into bundle
|
||||||
test -d QupZilla.app/Contents/Resources/plugins || mkdir QupZilla.app/Contents/Resources/plugins
|
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
|
# 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
|
# fix plugins
|
||||||
for plugin in QupZilla.app/Contents/Resources/plugins*.dylib
|
for plugin in QupZilla.app/Contents/Resources/plugins/*.dylib
|
||||||
do
|
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
|
done
|
||||||
|
|
||||||
# run macdeployqt
|
# run macdeployqt
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
#include "profileupdater.h"
|
#include "profileupdater.h"
|
||||||
#include "qupzilla.h"
|
#include "qupzilla.h"
|
||||||
#include "updater.h"
|
#include "updater.h"
|
||||||
|
#include "globalfunctions.h"
|
||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ProfileUpdater::ProfileUpdater(const QString &profilePath)
|
ProfileUpdater::ProfileUpdater(const QString &profilePath)
|
||||||
|
@ -111,7 +113,18 @@ void ProfileUpdater::copyDataToProfile()
|
||||||
QDir profileDir(m_profilePath);
|
QDir profileDir(m_profilePath);
|
||||||
profileDir.mkdir("certificates");
|
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:<br/><br/><b>" + browseDataBackup + "<br/>" + settingsBackup + "<br/></b>";
|
||||||
|
QMessageBox::warning(0, "QupZilla: Incompatible profile version", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
browseData.remove();
|
||||||
QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db");
|
QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db");
|
||||||
QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser);
|
QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,33 @@ QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||||
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
||||||
m_file.close();
|
m_file.close();
|
||||||
|
|
||||||
bookmarks = bookmarks.mid(0, bookmarks.lastIndexOf("</DL><p>"));
|
|
||||||
int start = bookmarks.indexOf("<DL><p>", Qt::CaseInsensitive);
|
// Converting tags to lower case -,-
|
||||||
|
// For some reason Qt::CaseInsensitive is not everytime insensitive :-D
|
||||||
|
|
||||||
|
bookmarks.replace("<DL", "<dl");
|
||||||
|
bookmarks.replace("</DL", "</dl");
|
||||||
|
bookmarks.replace("<DT", "<dt");
|
||||||
|
bookmarks.replace("</DT", "</dt");
|
||||||
|
bookmarks.replace("<P", "<p");
|
||||||
|
bookmarks.replace("</P", "</p");
|
||||||
|
bookmarks.replace("<A", "<a");
|
||||||
|
bookmarks.replace("</A", "</a");
|
||||||
|
bookmarks.replace("HREF=", "href=");
|
||||||
|
bookmarks.replace("<H3", "<h3");
|
||||||
|
bookmarks.replace("</H3", "</h3");
|
||||||
|
|
||||||
|
bookmarks = bookmarks.mid(0, bookmarks.lastIndexOf("</dl><p>"));
|
||||||
|
int start = bookmarks.indexOf("<dl><p>");
|
||||||
|
|
||||||
QStringList folders("Html Import");
|
QStringList folders("Html Import");
|
||||||
|
|
||||||
while (start > 0) {
|
while (start > 0) {
|
||||||
QString string = bookmarks.mid(start);
|
QString string = bookmarks.mid(start);
|
||||||
|
|
||||||
int posOfFolder = string.indexOf("<DT><H3", Qt::CaseInsensitive);
|
int posOfFolder = string.indexOf("<dt><h3");
|
||||||
int posOfEndFolder = string.indexOf("</DL><p>", Qt::CaseInsensitive);
|
int posOfEndFolder = string.indexOf("</dl><p>");
|
||||||
int posOfLink = string.indexOf("<DT><A", Qt::CaseInsensitive);
|
int posOfLink = string.indexOf("<dt><a");
|
||||||
|
|
||||||
int nearest = qzMin(posOfLink, qzMin(posOfFolder, posOfEndFolder));
|
int nearest = qzMin(posOfLink, qzMin(posOfFolder, posOfEndFolder));
|
||||||
if (nearest == -1) {
|
if (nearest == -1) {
|
||||||
|
@ -85,7 +101,7 @@ QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||||
|
|
||||||
if (nearest == posOfFolder) {
|
if (nearest == posOfFolder) {
|
||||||
// Next is folder
|
// Next is folder
|
||||||
QRegExp rx("<DT><H3(.*)>(.*)</H3>", Qt::CaseInsensitive);
|
QRegExp rx("<dt><h3(.*)>(.*)</h3>");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(string);
|
rx.indexIn(string);
|
||||||
|
|
||||||
|
@ -98,20 +114,22 @@ QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||||
}
|
}
|
||||||
else if (nearest == posOfEndFolder) {
|
else if (nearest == posOfEndFolder) {
|
||||||
// Next is end of folder
|
// Next is end of folder
|
||||||
folders.removeLast();
|
if (!folders.isEmpty()) {
|
||||||
|
folders.removeLast();
|
||||||
|
}
|
||||||
|
|
||||||
start += posOfEndFolder + 8;
|
start += posOfEndFolder + 8;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Next is link
|
// Next is link
|
||||||
QRegExp rx("<DT><A(.*)>(.*)</A>", Qt::CaseInsensitive);
|
QRegExp rx("<dt><a(.*)>(.*)</a>");
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
rx.indexIn(string);
|
rx.indexIn(string);
|
||||||
|
|
||||||
QString arguments = rx.cap(1);
|
QString arguments = rx.cap(1);
|
||||||
QString linkName = rx.cap(2);
|
QString linkName = rx.cap(2);
|
||||||
|
|
||||||
QRegExp rx2("HREF=\"(.*)\"", Qt::CaseInsensitive);
|
QRegExp rx2("href=\"(.*)\"");
|
||||||
rx2.setMinimal(true);
|
rx2.setMinimal(true);
|
||||||
rx2.indexIn(arguments);
|
rx2.indexIn(arguments);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user