From ec5bd41cb58a251bc541aa480a293101573abb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sun, 14 Feb 2021 14:20:13 +0200 Subject: [PATCH 1/1] SidebarWidget: Handling feed entry URLs with spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sidebar failed to realize that an entry was the current one and/or already read, because URL encoding is not consistently applied. This needs addressing soon — internally, all URLs should have a consistent format (fully encoded or decoded, NFC normalized). --- src/app.c | 2 +- src/ui/sidebarwidget.c | 5 ++++- src/ui/window.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app.c b/src/app.c index 3d4c5dc3..f5833c95 100644 --- a/src/app.c +++ b/src/app.c @@ -1272,7 +1272,7 @@ iBool handleCommand_App(const char *cmd) { iDocumentWidget *doc = document_Command(cmd); const int newTab = argLabel_Command(cmd, "newtab"); if (newTab) { - doc = newTab_App(NULL, (newTab & 1) != 0); /* "newtab:2" to open in background */ + doc = newTab_App(NULL, (newTab & 1) != 0); /* `newtab:2` to open in background */ } iHistory *history = history_DocumentWidget(doc); const iBool isHistory = argLabel_Command(cmd, "history") != 0; diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index dc1a60dc..679d8e6f 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -134,7 +134,8 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { d->menu = NULL; switch (d->mode) { case feeds_SidebarMode: { - const iString *docUrl = url_DocumentWidget(document_App()); + const iString *docUrl = withSpacesEncoded_String(url_DocumentWidget(document_App())); + /* TODO: internal URI normalization */ iTime now; iDate on; initCurrent_Time(&now); @@ -490,6 +491,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) { d->list = new_ListWidget(); setPadding_Widget(as_Widget(d->list), 0, gap_UI, 0, gap_UI); addChild_Widget(content, iClob(d->list)); + d->contextItem = NULL; d->blank = new_Widget(); addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag); addChildFlags_Widget(vdiv, iClob(content), expand_WidgetFlag); @@ -1037,6 +1039,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) } if (d->menu && ev->type == SDL_MOUSEBUTTONDOWN) { if (ev->button.button == SDL_BUTTON_RIGHT) { + d->contextItem = NULL; if (!isVisible_Widget(d->menu)) { updateMouseHover_ListWidget(d->list); } diff --git a/src/ui/window.c b/src/ui/window.c index 5101ed9b..3958f682 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -398,7 +398,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { iInputWidget *url = findWidget_App("url"); const iString *urlStr = collect_String(suffix_Command(cmd, "url")); trimCache_App(); - visitUrl_Visited(visited_App(), urlStr, 0); + visitUrl_Visited(visited_App(), withSpacesEncoded_String(urlStr), 0); /* TODO: internal URI normalization */ postCommand_App("visited.changed"); /* sidebar will update */ setText_InputWidget(url, urlStr); checkLoadAnimation_Window_(get_Window()); @@ -723,6 +723,7 @@ iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) { void init_Window(iWindow *d, iRect rect) { theWindow_ = d; + d->win = NULL; iZap(d->cursors); d->initialPos = rect.pos; d->lastRect = rect; -- 2.34.1