[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19555: shr-urlify: undecoded URIs make help-echo unhelpful
From: |
Ivan Shmakov |
Subject: |
bug#19555: shr-urlify: undecoded URIs make help-echo unhelpful |
Date: |
Sat, 10 Jan 2015 12:17:33 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Package: emacs
Severity: minor
As of 88bc8332eb14 (2015-01-07 13:51:41 +0000), shr-urlify
stores an undecoded URI as the link text’s help-echo property,
while it should most probably use a decoded IRI string instead.
The net effect is that, for instance, while TABbing over some
Russian Wikipedia article, the user may stumble upon:
https://ru.wikipedia.org/wiki/%D0%A4%D0%BE%D0%BD%D0%B4_%D1%81%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%BD%D0%BE%D0%B3%D0%BE_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE%D0%B3%D0%BE_%D0%BE%D0%B1%D0%B5%D1%81%D0%BF%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D1%8F
instead of the (arguably) much more readable:
https://ru.wikipedia.org/wiki/Фонд_свободного_программного_обеспечения
Since 2014-11-19, I use the code MIMEd to use the decoded string
for help-echo instead, – yet I doubt the code’s correctness.
For one thing, I’m pretty sure that I’ve seen non-UTF-8 codings
being used for %-encoded URIs, and this change does by no means
takes that into account. Another concern is that in its current
form, it /does/ decode %20s into blanks, invalidating the IRI.
EWW should probably also use the decoded form while filing
eww-data :url entry (subject to the concerns above.)
--
FSF associate member #7257 np. Brighter Than a Thousand Suns — Iron Maiden
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -894,7 +918,13 @@ defun shr-urlify (start url &optional title)
(add-text-properties
start (point)
(list 'shr-url url
- 'help-echo (if title (shr-fold-text (format "%s (%s)" url title)) url)
+ 'help-echo (let ((iri (or (with-demoted-errors
+ "shr-urlify: %s"
+ (decode-coding-string
+ (url-unhex-string url)
+ 'utf-8 t))
+ url)))
+ (if title (format "%s (%s)" iri title) iri))
'follow-link t
'mouse-face 'highlight
'keymap shr-map)))
- bug#19555: shr-urlify: undecoded URIs make help-echo unhelpful,
Ivan Shmakov <=