all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68913: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate
@ 2024-02-03 19:17 Kenta USAMI
  2024-02-03 19:49 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Kenta USAMI @ 2024-02-03 19:17 UTC (permalink / raw)
  To: 68913


[-- Attachment #1.1: Type: text/plain, Size: 948 bytes --]

Hi,

In the text below, move point to the second half of the URL and
execute M-x browse-url-at-point.

```
[![Emacs](
https://www.gnu.org/software/emacs/images/emacs.png)](https://www.gnu.org/software/emacs/download.html
)
```

Firefox and Chromium-based browsers appear to open the URL "https//
www.gnu.org/software/emacs/download.html".
It seems that the ":" following https is deleted, but the browser actually
normalizes
the URL with the duplicate scheme "http://https://".

You can check this by executing M-: (browse-url-url-at-point).

Because thing-at-point-bounds-of-url-at-point function cannot correctly
recognize
URL bounds in the text.

I considered changing the thing-at-point-bounds-of-url-at-point algorithm,
but it would be a pain to change it without negatively impacting the
current behavior.
Ideally, thing-at-point-bounds-of-url-at-point will be fixed eventually,
but for now, the attached patch should easily fix the problem.

[-- Attachment #1.2: Type: text/html, Size: 1424 bytes --]

[-- Attachment #2: 0001-Fix-browse-url-url-at-point-so-that-scheme-does-not-.patch --]
[-- Type: application/octet-stream, Size: 1079 bytes --]

From 09082305dbe87620657cf9d6c3fe0c058deee800 Mon Sep 17 00:00:00 2001
From: USAMI Kenta <tadsan@zonu.me>
Date: Sun, 4 Feb 2024 03:20:24 +0900
Subject: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate

---
 lisp/net/browse-url.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 359453ca43..bc2a7db9a8 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -688,8 +688,10 @@ browse-url-default-scheme
 (defun browse-url-url-at-point ()
   (or (thing-at-point 'url t)
       ;; assume that the user is pointing at something like gnu.org/gnu
-      (let ((f (thing-at-point 'filename t)))
-        (and f (concat browse-url-default-scheme "://" f)))))
+      (when-let ((f (thing-at-point 'filename t)))
+	(if (string-match-p browse-url-button-regexp f)
+	    f
+	  (concat browse-url-default-scheme "://" f)))))
 
 ;; Having this as a separate function called by the browser-specific
 ;; functions allows them to be stand-alone commands, making it easier
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-08 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-03 19:17 bug#68913: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate Kenta USAMI
2024-02-03 19:49 ` Eli Zaretskii
2024-02-03 20:48   ` Kenta USAMI
2024-02-03 20:59     ` Kenta USAMI
2024-02-08 12:07     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.