bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40241: Acknowledgement (26.1; browse-url, needs to % hex hex encode


From: larice
Subject: bug#40241: Acknowledgement (26.1; browse-url, needs to % hex hex encode the hash char)
Date: Thu, 26 Mar 2020 17:49:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

> Dear Maintainers,
> 
>   I couldn't open a link in org mode, which happened
>     to contain a hash char #.
>   A search for the culprit revealed usage of this
>     (setq url (browse-url-encode-url url))
>   in several functions,
>   for example in browse-url-firefox in file browse-url.el
> 
>   This function looks like:
> 
>   (defun browse-url-encode-url (url)
>   "Escape annoying characters in URL.
> The annoying characters are those that can mislead a web browser
> regarding its parameter treatment."
>   ;; FIXME: Is there an actual example of a web browser getting
>   ;; confused?  (This used to encode commas, but at least Firefox
>   ;; handles commas correctly and doesn't accept encoded commas.)
>   (browse-url-url-encode-chars url "[\")$] "))
> 
>   I suggest to add the char '#' to the second argument of the
>     browse-url-url-encode-chars invocation to fix the nuisance.

I've to correct myself, and to withdraw my suggestion.
The '#' char has special significance in rfc3986 and can't be
  that easily % hex'ified.

My issue is more precisely the following.
I've URLs for the search engine of "murata" which look like:
  
http://www.murata.com/en-global/products/productdetail?partno=GRM21BR61E226ME44#
At first sight this looks well, but note the trailing '#'.
When I enter this interactively into firefox, then it works.
If I use %23 instead, it works too.
If I pass the URL on the firefox command line, then only the %23 variant works.
If I use such an URL in a org mode file, either with # or with %23,
  then this URL gets un-hexlified to the '#' variant somewhere in
  org-mode, is then passed to `browse-url-firefox', which passes it
  unmodified to the command line of a firefox invocation.
But that's the variant which doesn't work for firefox.

Now this is too exotic, and I simply withdraw my `bug' report.
I don't think it is worth the time,
neither is it easy to exactly state whats wrong here at all.
Perhaps it is the part of org mode which
 un-hexlifies the URL. I suppose it shouldn't.
Then I could have put a %23'fied URL into the org file.

As this case is exotic and very specific,
I simply add an exception rule to `browse-url-browser-function'
 like this

(defun my-browse-url-generic (url &optional new-window)
  (browse-url-generic (browse-url-url-encode-chars url "#") new-window))

(setq browse-url-browser-function
      '(("murata.*#$" . my-browse-url-generic)
        ("." . browse-url-generic)))

and be done with it.
Sorry for having wasted your time.

Best Regards
 Robert Larice

 
 
  







reply via email to

[Prev in Thread] Current Thread [Next in Thread]