Skip to content

Commit

Permalink
fix: url encoding
Browse files Browse the repository at this point in the history
Change-Id: Ia663a0b112f27354b8fd4e9ee32be8e522061e89
  • Loading branch information
reionwong committed Nov 19, 2018
1 parent 2638581 commit 4a6b7b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util/drecentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ bool DRecentManager::addItem(const QString &uri, DRecentData &data)
file.close();

// need to add file:// protocol.
QUrl url(uri);
url.setScheme("file");
QUrl url = QUrl::fromLocalFile(uri);

// get the MimeType name of the file.
if (data.mimeType.isEmpty()) {
Expand All @@ -99,7 +98,7 @@ bool DRecentManager::addItem(const QString &uri, DRecentData &data)
for (int i = 0; i < nodeList.size(); ++i) {
const QString fileUrl = nodeList.at(i).toElement().attribute("href");

if (fileUrl == url.toString()) {
if (fileUrl == url.toEncoded(QUrl::FullyDecoded)) {
bookmarkEle = nodeList.at(i).toElement();
isFound = true;
break;
Expand Down Expand Up @@ -142,7 +141,7 @@ bool DRecentManager::addItem(const QString &uri, DRecentData &data)
// add new elements if they don't exist.
else {
QDomElement bookmarkEle, infoEle, metadataEle, mimeEle, appsEle, appChildEle;
QString hrefStr = QString::fromLatin1(url.toEncoded(QUrl::FullyEncoded));
QString hrefStr = url.toEncoded(QUrl::FullyEncoded);

bookmarkEle = doc.createElement("bookmark");
bookmarkEle.setAttribute("href", hrefStr);
Expand Down Expand Up @@ -227,7 +226,8 @@ void DRecentManager::removeItems(const QStringList &list)
for (int i = 0; i < nodeList.count(); ) {
const QString fileUrl = nodeList.at(i).toElement().attribute("href");

if (list.contains(QUrl::fromPercentEncoding(fileUrl.toUtf8()))) {
if (list.contains(QUrl::fromPercentEncoding(fileUrl.toLatin1())) ||
list.contains(QUrl(fileUrl).toEncoded(QUrl::FullyDecoded))) {
rootEle.removeChild(nodeList.at(i));
} else {
++i;
Expand Down

0 comments on commit 4a6b7b6

Please sign in to comment.