From 303c3cc534e3f606528433b176d7133d46a5200f Mon Sep 17 00:00:00 2001
From: Jeremy Visser <jeremy.visser@gmail.com>
Date: Wed, 4 Nov 2026 13:04:37 +1100
Subject: browser_window: fix back history for meta redirect

This fixes a bug which otherwise causes it to be impossible to return to
the target of a meta http-equiv redirect after navigating once, if the
redirect is itself (intentionally) random.

At time of writing, https://wiby.me/ has a "surprise me!" link
(https://wiby.me/surprise/) which can reproduce the problem.

The underlying reproduction steps are:

  1. Navigate to refresh.html, which contains:

         <meta http-equiv="refresh" content="0;url=target.html">

  2. target.html loads, which contains:

         <a href="other.html>other.html</a>

  3. Click link (other.html), and press Back

  4. - Expectation: back to target.html
     - Reality:     back to refresh.html
       - If refresh.html is random (i.e. subsequently redirects to
         target2.html), it will be impossible to go back to target.html

BW_NAVIGATE_HISTORY is used to indicate whether to create a history
entry for this particular navigation.

For example, clicking Back/Forward is itself a form of navigation that should
*not* cause a new history entry.

A meta http-equiv refresh that redirects to the same page repeatedly should
also *not* cause a history entry

But a http-equiv redirect to a *different* page *should* cause a history
entry, since it's a page the user will actually land on.
---
 desktop/browser_window.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index 226741be5..5c108a539 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -638,7 +638,7 @@ static void browser_window_refresh(void *p)
 	content_invalidate_reuse_data(bw->current_content);
 
 	url = hlcache_handle_get_url(bw->current_content);
-	if ((url == NULL) || (nsurl_compare(url, refresh, NSURL_COMPLETE))) {
+	if ((url == NULL) || (!nsurl_compare(url, refresh, NSURL_COMPLETE))) {
 		flags |= BW_NAVIGATE_HISTORY;
 	}
 
-- 
cgit v1.2.3

