Subject: [PATCH] Retain the <base> tag when making a page in EWW document readable
From: Steven Allen <[email-masked]>
To: [email-masked]
Date: Wed, 02 Jul 2025 14:37:27 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Retain the <base> tag when making a page in EWW document
readable. Otherwise, relative links aren't resolved correctly.

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
 1.18.4) of 2025-07-02 built on Laptop
Repository revision: bf7d9f3c47ee59d45129d08490411e572a737db5
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12101018
System Description: Arch Linux

Configured using:
 'configure
 'CPPFLAGS=-I/run/user/1000/build/emacs-git/src/mps-git/build/include '
 'LDFLAGS=-L/run/user/1000/build/emacs-git/src/mps-git/build/lib -Wl,-O1
 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
 -Wl,-z,pack-relative-relocs -flto=auto' --prefix=/usr --sysconfdir=/etc
 --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man
 --with-gameuser=:games --with-modules --without-m17n-flt
 --without-selinux --without-pop --without-gconf --disable-gc-mark-trace
 --with-mps=yes --enable-link-time-optimization
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=no
 --without-toolkit-scroll-bars --without-xaw3d --without-gsettings
 --with-cairo-xcb --without-xft --with-sound=no --with-tree-sitter
 --without-gpm --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=native -mtune=native -O3 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -fomit-frame-pointer
 -fno-math-errno -fno-trapping-math -fno-math-errno -fno-trapping-math
 -flto=auto''

From a681cc767b1124bed84432ebb062f110383ede68 Mon Sep 17 00:00:00 2001
From: Steven Allen <[email-masked]>
Date: Wed, 2 Jul 2025 14:32:28 -0700
Subject: [PATCH] Retain the <base> tag when making a page in EWW document
 readable

The base tag is necessary to correctly resolve relative links.

* lisp/net/eww.el (eww-readable-dom): Retain the base tag in addition to
the title/link tags.
---
 lisp/net/eww.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 2f99234c47d..76dccaec9dd 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1225,7 +1225,7 @@ eww-readable-dom
          ;; "previous" pages.  NOTE: We could probably filter out
          ;; stylesheet <link> tags here, though it doesn't really matter
          ;; since we don't *do* anything with stylesheets...
-         (when (memq (dom-tag node) '(title link))
+         (when (memq (dom-tag node) '(title link base))
            ;; Copy the node, but not any of its (non-text) children.
            ;; This way, we can ensure that we don't include a node
            ;; directly in our list in addition to as a child of some
-- 
2.50.0