From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kenta USAMI Newsgroups: gmane.emacs.bugs Subject: bug#68913: [PATCH] Fix browse-url-url-at-point so that scheme does not duplicate Date: Sun, 4 Feb 2024 05:59:48 +0900 Message-ID: References: <86o7cx2ur6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000f821f50610808245" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38085"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68913@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 03 22:01:32 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rWN8l-0009ia-3I for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Feb 2024 22:01:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWN88-0006rL-Nn; Sat, 03 Feb 2024 16:00:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWN87-0006qm-4y for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 16:00:51 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWN86-0003mI-TB for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 16:00:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rWN8I-0006A2-CS for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2024 16:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kenta USAMI Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Feb 2024 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68913 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68913-submit@debbugs.gnu.org id=B68913.170699401923588 (code B ref 68913); Sat, 03 Feb 2024 21:01:02 +0000 Original-Received: (at 68913) by debbugs.gnu.org; 3 Feb 2024 21:00:19 +0000 Original-Received: from localhost ([127.0.0.1]:47146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWN7a-00068K-Ou for submit@debbugs.gnu.org; Sat, 03 Feb 2024 16:00:19 -0500 Original-Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]:46429) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWN7Z-000686-2S for 68913@debbugs.gnu.org; Sat, 03 Feb 2024 16:00:17 -0500 Original-Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2cf2fdd518bso38980311fa.1 for <68913@debbugs.gnu.org>; Sat, 03 Feb 2024 13:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zonu-me.20230601.gappssmtp.com; s=20230601; t=1706993999; x=1707598799; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S9OC+ItJN8H3DZKBvz1vaSOD1be1aJvsOY2HWD7xj0c=; b=Da+AMSlNIgwh9ykIyHC3DPeAW+0O1Dk1EDFEgO9wo2BN/1ZQGOhoRbB8FTxkl0r0j+ AZ9khCwtHcb/DjvGbAWydiLhHvNiP+otblZIk2bLZCeMKdorVRurUnNVX7Kz+Ic5kx22 yS/beGw195XvSlpCK/xpGrNRbSihYdq8lMYfh3j12hiiGAOtPk8sYxG+65LE64qsCAiM UkhyIM8PVdxiEuClQpP1/1y80GG+tAoX8+I9a8nljQ1q/w4QwGmSZ/py23d0reIJVDG3 ASRrPpJQeUvAh5dc9QKgsjty8DeS83b7wIi1oSZT0w9TPvGZWmy6akMNkPes6D8Epw4+ BMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706993999; x=1707598799; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S9OC+ItJN8H3DZKBvz1vaSOD1be1aJvsOY2HWD7xj0c=; b=N5rs0yn5mZ5uDYlowWKKOdm+2z5PO6nm5jMUyLTmtMQ4V8IpkzUs5zaI54EmOSm0Ei B9/G4nCrZcHK9TI+bYb9F3PcTrEU/ywagqOpiH0MVcss5cHPPOt0gBDUkbIZ4nBoHgns P1p57uBf43tbZIqAwPFn27XLks5vZnDFAcioFDQroS5jnrrEmKWlF8FgjSCATbq2tvsH DT3BQC0Qy1iSZLQzyYnuW+eAlfC3rEV+eDcGraFiXBT5ndrmwrLiUUsNKN/UmFGK/ZfT OWxwVQyAkroq3yhZNwLtaCUlMDhMDdrXdNUa0tp0uz1bxjt8QEtrpJPbp8RdBhXsEdGe Fvxg== X-Gm-Message-State: AOJu0YzE9qbEgU5oOvasg7qKqX3rvmiERYLPfEjgR+w6g9ZUWeNYmib8 ttTxKULJaYdafz/NHvKs9R1dqQxWqgEyftvFqu0VeZ1vMEruPyEffb6Mgx08en9PsZlj8xO1WD+ 9BZOwO18Afty94WnkgnCdGe+sT/2b8EP6cwachRZUgudlaEt+7JBtoQ== X-Google-Smtp-Source: AGHT+IEzUFZ4mnogK3zOkavpCTnouM4qwub3BsxCZO0340zg61loVha6BwQK9IAplYl4/jvEmFqDH6C81pHnDDJaHig= X-Received: by 2002:a05:651c:150d:b0:2d0:69c4:c701 with SMTP id e13-20020a05651c150d00b002d069c4c701mr8186610ljf.31.1706993999412; Sat, 03 Feb 2024 12:59:59 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279382 Archived-At: --000000000000f821f50610808245 Content-Type: multipart/alternative; boundary="000000000000f821f40610808243" --000000000000f821f40610808243 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I forgot that MUA can insert newlines on long lines. Resend the test code to the URL and attachment below. https://gitlab.com/-/snippets/3650077 2024=E5=B9=B42=E6=9C=884=E6=97=A5(=E6=97=A5) 5:48 Kenta USAMI : > I'm using Emacs 29.2 on macOS. > GNU Emacs 29.2 (build 2, aarch64-apple-darwin23.3.0, NS appkit-2487.40 > Version 14.3 (Build 23D56)) > of 2024-01-26 > > This problem is most noticeable when using markdown-mode and > goto-address-mode, > but it also seems to occur even if goto-address-mode is disabled in > text-mode or fundamental-mode. > > You can see the problem by evaluating the Lisp code below. > > ;;; foo.el > (require 'ert) > (require 'browse-url) > > (ert-deftest test-browse-url-url-at-point () > (let* ((text " > [![Emacs]( > https://www.gnu.org/software/emacs/images/emacs.png)](https://www.gnu.org= /software/emacs/download.html > ) > ") > (expected "https://www.gnu.org/software/emacs/download.html") > (actual (with-temp-buffer > (insert text) > (goto-char 76) > (browse-url-url-at-point)))) > (should (string=3D expected actual)))) > > Evaluate the expression directly in the buffer or save it to a file and > check it with the command below. > > $ emacs --batch -l foo.el -f ert-run-tests-batch-and-exit > > 2024=E5=B9=B42=E6=9C=884=E6=97=A5(=E6=97=A5) 4:49 Eli Zaretskii : > >> > From: Kenta USAMI >> > Date: Sun, 4 Feb 2024 04:17:29 +0900 >> > >> > 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.or= g/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://". >> >> In what version of Emacs did you see that? And on what OS? >> >> Also, please post a complete recipe: do I type the above into the >> *scratch* buffer, or into some other buffer, and what should be the >> major-mode of that buffer? Also, is the part inside [...] that >> precedes the URL important for reproducing the problem? >> >> Thanks. >> > --000000000000f821f40610808243 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I forgot that MUA can insert newlines on long lines.<= br>
Resend the test code to the URL and attachment below.
https://gitlab.com/-/snippets/36= 50077

2024=E5=B9=B42=E6=9C=884=E6=97=A5(=E6=97=A5) 5:48 Kenta USAMI = <zonuexe@zonu.me>:
I'= ;m using Emacs 29.2 on macOS.
GNU Emacs 29.2 (build 2, aarch64-apple-dar= win23.3.0, NS appkit-2487.40 Version 14.3 (Build 23D56))
=C2=A0of 2024-0= 1-26

This problem is most noticeable when using markdown-= mode and goto-address-mode,=C2=A0
but it also seems to occur even= if goto-address-mode is disabled in text-mode or fundamental-mode.

You can see the problem by evaluating the Lisp code below= .

;;; foo.el
(require 'ert)
(= require 'browse-url)

(ert-deftest test-browse-url-url-at-point (= )
=C2=A0 (let* ((text "
[![Emacs](https://www.gnu.org/software/emacs/images/ema= cs.png)](https://www.gnu.org/software/emacs/download.html)
")=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(expected "https://www.gnu.org= /software/emacs/download.html")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(actual (with-temp-buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert text)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char 76)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(browse-url-url-at-poin= t))))
=C2=A0 =C2=A0 (should (string=3D expected actual))))

=
Evaluate the expression directly in the buffer or save it to a file an= d check it with the command below.

$ emacs --b= atch -l foo.el -f ert-run-tests-batch-and-exit

2024=E5=B9=B42=E6=9C=88= 4=E6=97=A5(=E6=97=A5) 4:49 Eli Zaretskii <eliz@gnu.org>:
> From: Kenta USAMI <zonuexe@zonu.me>
> Date: Sun, 4 Feb 2024 04:17:29 +0900
>
> 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&quo= t;.
> It seems that the ":" following https is deleted, but the br= owser actually
> normalizes
> the URL with the duplicate scheme "http://https://".

In what version of Emacs did you see that?=C2=A0 And on what OS?

Also, please post a complete recipe: do I type the above into the
*scratch* buffer, or into some other buffer, and what should be the
major-mode of that buffer?=C2=A0 Also, is the part inside [...] that
precedes the URL important for reproducing the problem?

Thanks.
--000000000000f821f40610808243-- --000000000000f821f50610808245 Content-Type: application/octet-stream; name="foo.el" Content-Disposition: attachment; filename="foo.el" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ls6k3o2t0 KHJlcXVpcmUgJ2VydCkKKHJlcXVpcmUgJ2Jyb3dzZS11cmwpCgooZXJ0LWRlZnRlc3QgdGVzdC1i cm93c2UtdXJsLXVybC1hdC1wb2ludCAoKQogIChsZXQqICgodGV4dCAiClshW0VtYWNzXShodHRw czovL3d3dy5nbnUub3JnL3NvZnR3YXJlL2VtYWNzL2ltYWdlcy9lbWFjcy5wbmcpXShodHRwczov L3d3dy5nbnUub3JnL3NvZnR3YXJlL2VtYWNzL2Rvd25sb2FkLmh0bWwpCiIpCiAgICAgICAgIChl eHBlY3RlZCAiaHR0cHM6Ly93d3cuZ251Lm9yZy9zb2Z0d2FyZS9lbWFjcy9kb3dubG9hZC5odG1s IikKICAgICAgICAgKGFjdHVhbCAod2l0aC10ZW1wLWJ1ZmZlcgogICAgICAgICAgICAgICAgICAg KGluc2VydCB0ZXh0KQogICAgICAgICAgICAgICAgICAgKGdvdG8tY2hhciA3NikKICAgICAgICAg ICAgICAgICAgIChicm93c2UtdXJsLXVybC1hdC1wb2ludCkpKSkKICAgIChzaG91bGQgKHN0cmlu Zz0gZXhwZWN0ZWQgYWN0dWFsKSkpKQoK --000000000000f821f50610808245--