From efc10a2b3e5a795d9400376fab30f1d6dff6dbf4 Mon Sep 17 00:00:00 2001 From: makeworld Date: Thu, 1 Oct 2020 19:08:26 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20allow=20creation=20of=20?= =?UTF-8?q?invalid=20bkmks=20-=20fixes=20#95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display/bookmarks.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/display/bookmarks.go b/display/bookmarks.go index 0b4f0c4..8541751 100644 --- a/display/bookmarks.go +++ b/display/bookmarks.go @@ -134,16 +134,22 @@ func Bookmarks(t *tab) { // It is the high-level way of doing it. It should be called in a goroutine. // It can also be called to edit an existing bookmark. func addBookmark() { - curPage := tabs[curTab].page - name, exists := bookmarks.Get(curPage.URL) + t := tabs[curTab] + p := t.page + + if !t.hasContent() { + // It's an about: page, or a malformed one + return + } + name, exists := bookmarks.Get(p.URL) // Open a bookmark modal with the current name of the bookmark, if it exists - newName, action := openBkmkModal(name, exists, curPage.Favicon) + newName, action := openBkmkModal(name, exists, p.Favicon) switch action { case 1: // Add/change the bookmark - bookmarks.Set(tabs[curTab].page.URL, newName) + bookmarks.Set(p.URL, newName) case -1: - bookmarks.Remove(tabs[curTab].page.URL) + bookmarks.Remove(p.URL) } // Other case is action = 0, meaning "Cancel", so nothing needs to happen }