all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenta USAMI <zonuexe@zonu.me>
To: 68913@debbugs.gnu.org
Subject: bug#68913: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate
Date: Sun, 4 Feb 2024 04:17:29 +0900	[thread overview]
Message-ID: <CAJB2i6Zj=iBiM5JtkWdXFsmaogNxD9mBZ6t1SahjZLwaWrRC3g@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2024-02-03 19:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-03 19:17 Kenta USAMI [this message]
2024-02-03 19:49 ` bug#68913: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate Eli Zaretskii
2024-02-03 20:48   ` Kenta USAMI
2024-02-03 20:59     ` Kenta USAMI
2024-02-08 12:07     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJB2i6Zj=iBiM5JtkWdXFsmaogNxD9mBZ6t1SahjZLwaWrRC3g@mail.gmail.com' \
    --to=zonuexe@zonu.me \
    --cc=68913@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.