unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Decoding URLs input
Date: Sat, 3 Jul 2021 22:17:39 +0300	[thread overview]
Message-ID: <YOC305ybCww3HsWh@protected.localdomain> (raw)
In-Reply-To: <CAP_d_8WpokFrwzv=6ECqrbv_AX0V3nSYGOx+DBrcshqBV+piXA@mail.gmail.com>

* Yuri Khan <yuri.v.khan@gmail.com> [2021-07-03 14:12]:
> What you are dealing with is a URL, specifically, its query string
> part. These are described in RFC 3986, and its percent-encoding scheme
> in sections 2.1 and 2.5.
> 
> (url-unhex-string …) will do half the work for you: It will decode
> percent-encoded sequences into bytes. By convention, in URLs,
> characters are UTF-8-encoded before percent-encoding (see RFC 3986 §
> 2.5), so you’ll need to use:
> 
>     (decode-coding-string (url-unhex-string s) 'utf-8)
> 
> to get a fully decoded text string.

That is very correct and I have implemented that now. Until now it
worked without `decode-coding-string' and I totally forgot UTF-8. When
I faced the fact that spaces are replaced with plus `+' I started
diggin more. It is not first time to deal with it, who knows which
time and each time I stumble upon UTF-8 handlings, this time you were
one step ahead of me, I have not stumbled upon it and could not
discover what is missing.

From docstring of `url-unhex-string' I did not expect it would give
just bytes back, then that should be IMHO described there, I am not
sure really. Maybe it is assumed for programmer to know that. The
docstring is poor, it says like: "Remove %XX embedded spaces, etc in a
URL." -- with "remove" I don't expect converting UTF-8 into bytes.

I guess now it is clear.

I am now solving the issue that spaces are converted to plus sign and
that I have to convert + signs maybe before:
(decode-coding-string (url-unhex-string "Hello+There") 'utf-8)
but maybe not before, maybe I leave it and convert later.

Problem I have encountered is that library subr.el does not provide
feature 'subr -- and I think I did file report but without
acknowledgment and without seeing it being filed under my email. So I
wait. 

So I cannot use in CGI script the function `string-replace' or as it
asks for that file but I cannot `require' it, as it is not
"provided", so I have to add that line. I would not like really
fiddling on server with main Emacs files.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  parent reply	other threads:[~2021-07-03 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03  9:40 Decoding URLs input Jean Louis
2021-07-03  9:56 ` Jean Louis
2021-07-03 11:10 ` Yuri Khan
2021-07-03 12:04   ` Jean Louis
2021-07-03 19:17   ` Jean Louis [this message]
2021-07-03 20:16     ` Yuri Khan
2021-07-03 22:18       ` Jean Louis
2021-07-04  4:22       ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=YOC305ybCww3HsWh@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).