Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #3332 - Bookmarklet URLs not working properly with special characters #3349

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ class AddEditBookmarkTableViewController: UITableViewController {

switch saveLocation {
case .rootLevel:
bookmark.updateWithNewLocation(customTitle: title, url: url.absoluteString, location: nil)
bookmark.updateWithNewLocation(customTitle: title, url: url, location: nil)
case .favorites:
bookmark.delete()
Favorite.add(url: url, title: title)
case .folder(let folder):
bookmark.updateWithNewLocation(customTitle: title, url: urlString, location: folder)
bookmark.updateWithNewLocation(customTitle: title, url: url, location: folder)
}

case .editFolder(let folder):
Expand Down Expand Up @@ -301,7 +301,7 @@ class AddEditBookmarkTableViewController: UITableViewController {
favorite.delete()
Bookmarkv2.add(url: url, title: title)
case .favorites:
favorite.update(customTitle: title, url: url.absoluteString)
favorite.update(customTitle: title, url: url)
case .folder(let folder):
favorite.delete()
Bookmarkv2.add(url: url, title: title, parentFolder: folder)
Expand Down
16 changes: 8 additions & 8 deletions Client/Frontend/Sync/BraveCore/Bookmarkv2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ extension Bookmarkv2 {
.compactMap({ return !$0.isFolder ? Bookmarkv2($0) : nil })
}

public func update(customTitle: String?, url: String?) {
public func update(customTitle: String?, url: URL?) {
bookmarkNode.setTitle(customTitle ?? "")
bookmarkNode.url = URL(string: url ?? "")
bookmarkNode.url = url
}

public func updateWithNewLocation(customTitle: String?, url: String?, location: Bookmarkv2?) {
public func updateWithNewLocation(customTitle: String?, url: URL?, location: Bookmarkv2?) {
if let location = location?.bookmarkNode ?? Bookmarkv2.bookmarksAPI.mobileNode {
if location.guid != bookmarkNode.parent?.guid {
bookmarkNode.move(toParent: location)
Expand All @@ -249,7 +249,7 @@ extension Bookmarkv2 {
}

if let url = url, !bookmarkNode.isFolder {
bookmarkNode.url = URL(string: url)
bookmarkNode.url = url
} else if url != nil {
log.error("Error: Moving bookmark - Cannot convert a folder into a bookmark with url.")
}
Expand All @@ -272,10 +272,10 @@ extension Bookmarkv2 {
node.move(toParent: parent, index: UInt(destinationIndexPath.row))
}

//Notify the delegate that items did move..
//This is already done automatically in `Bookmarkv2Fetcher` listener.
//However, the Brave-Core delegate is being called before the move is actually complete OR too quickly
//So to fix it, we reload here AFTER the move is done so the UI can update accordingly.
// Notify the delegate that items did move..
// This is already done automatically in `Bookmarkv2Fetcher` listener.
// However, the Brave-Core delegate is being called before the move is actually complete OR too quickly
// So to fix it, we reload here AFTER the move is done so the UI can update accordingly.
frc.delegate?.controllerDidReloadContents(frc)
}
}
Expand Down