Received: (at submit) by debbugs.gnu.org; 25 Jun 2026 11:17:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 25 07:17:53 2026
Received: from localhost ([127.0.0.1]:60055 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1wci5Y-0002IJ-R0
for submit <at> debbugs.gnu.org; Thu, 25 Jun 2026 07:17:50 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:37018)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <manuel@HIDDEN>)
id 1wci5Q-0002HC-R0
for submit <at> debbugs.gnu.org; Thu, 25 Jun 2026 07:17:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <manuel@HIDDEN>)
id 1wci5A-0006Ge-DX
for bug-gnu-emacs@HIDDEN; Thu, 25 Jun 2026 07:17:28 -0400
Received: from ledu-giraud.fr ([51.159.28.247])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <manuel@HIDDEN>)
id 1wci56-00051f-Vn
for bug-gnu-emacs@HIDDEN; Thu, 25 Jun 2026 07:17:20 -0400
DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=As3O+W1g
Ffl++mR8RQxK6mKhhJE+3dB+IiYSladi5Sw=; h=date:subject:to:from;
d=ledu-giraud.fr;
b=ausBHq0z0V1CWQs1eZLXrg5m0TRJzJONxtxw2brOT1tWpye4VB
0niRkczRaB0rNrMSuhObv1KyExi4e1SmxYCw==
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=As3O+W1gFfl++mR8
RQxK6mKhhJE+3dB+IiYSladi5Sw=; h=date:subject:to:from;
d=ledu-giraud.fr; b=0FBqRHKy/J7Y+ZJknqRVgAhKcx1AN7LktiUr1FTPXlfJvfxyq8
6ucoR1CXknOuGrzWYJNhgv+AZ1Ez0yuaChyszYG0gUo7jV2inZyM64IWsWREN8t/yWu0Wd
faa3qP29Eum3YqVqECp+BIBf9+3bLzRY5mcFbW/ColdQhxsDc9RJhj7ij8H0TawnQWQXc9
hpID1+jsTzGU027bUUroCMonDJ0n2QdQe5+V9HM753yX+UNBHWy0mb1AxPWkkZlOwM2NNh
r5n6W72NEhkNbiW+rFAMJO8HBhLmb12oKllduqtySZvd9HutevWIRpUiKomPELp9w58pAj
9fA/8uc5wu/Q==
Received: from computer (<unknown> [10.1.1.1])
by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id c1d1bc93
(TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <bug-gnu-emacs@HIDDEN>;
Thu, 25 Jun 2026 13:17:14 +0200 (CEST)
From: Manuel Giraud <manuel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Remove text fragments from URL target
X-Debbugs-Cc: Lars Magne Ingebrigtsen <larsi@HIDDEN>
Date: Thu, 25 Jun 2026 13:17:13 +0200
Message-ID: <87fr2a7tty.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@HIDDEN;
helo=ledu-giraud.fr
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)
--=-=-=
Content-Type: text/plain
Tags: patch
Hi,
Some URL can have the following form:
https://narwhal.com/#nose:~:text=size
This is an extension of hashtag target named "text fragments" (See
https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment/Text_fragments)
This currently breaks in EWW because it will try to find a shr-target-id
property of value "nose:~:text=size" in this example. EWW should
instead look for a shr-target-id of value "nose".
This patch breaks such an extended target into the classical part and
the text fragments extension. For the moment, the text fragments part
is just thrown away and the classical part is used to look for the
correct shr-target-id.
In GNU Emacs 32.0.50 (build 7, x86_64-unknown-openbsd7.9) of 2026-06-24
built on computer
Repository revision: d5a10ea70872573aeacd947172fbf927f9c276b0
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101023
System Description: OpenBSD computer 7.9 GENERIC.MP#4 amd64
Configured using:
'configure CC=egcc CPPFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs
--bindir=/home/manuel/bin --with-x-toolkit=no
--with-toolkit-scroll-bars=no --without-cairo
--without-compress-install'
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
filename=0001-Remove-text-fragments-from-URL-target.patch
From adf0c7e76340e2f0795087aefbba18169ad997d6 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@HIDDEN>
Date: Thu, 25 Jun 2026 12:48:17 +0200
Subject: [PATCH] Remove text fragments from URL target
* lisp/net/eww.el (eww-parse-target): New function to parse a
more complex URL target.
(eww-render): Use it.
---
lisp/net/eww.el | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 542afa41180..1d812d66a38 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -686,6 +686,11 @@ eww--rename-buffer
(when rename-string
(rename-buffer rename-string t))))
+(defun eww-parse-target (target)
+ "Separate TARGET from its optional text fragments."
+ (string-match "\\([^:]*\\)\\(:~:\\)?\\(.*\\)" target)
+ (cons (match-string 1 target) (match-string 3 target)))
+
(defun eww-render (status url &optional point buffer encode)
(let* ((headers (eww-parse-headers))
(content-type
@@ -699,7 +704,8 @@ eww-render
(eww-detect-charset (eww-html-p (car content-type)))
"utf-8"))))
(data-buffer (current-buffer))
- (shr-target-id (url-target (url-generic-parse-url url)))
+ (full-target (eww-parse-target (url-target (url-generic-parse-url url))))
+ (shr-target-id (car full-target))
last-coding-system-used)
(let ((redirect (plist-get status :redirect)))
(when redirect
--
2.54.0
--=-=-=
Content-Type: text/plain
--
Manuel Giraud
--=-=-=--
Manuel Giraud <manuel@HIDDEN>:larsi@HIDDEN, bug-gnu-emacs@HIDDEN.
Full text available.larsi@HIDDEN, bug-gnu-emacs@HIDDEN:bug#81301; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.