From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Decoding URLs input Date: Sat, 03 Jul 2021 12:04:25 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4677"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help GNU Emacs To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 03 14:05:06 2021 Return-path: Envelope-to: geh-help-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 1lzeOP-0000yl-Lb for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Jul 2021 14:05:05 +0200 Original-Received: from localhost ([::1]:32986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzeOO-0001X6-Mx for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Jul 2021 08:05:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzeNy-0001WV-1v for help-gnu-emacs@gnu.org; Sat, 03 Jul 2021 08:04:38 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:37747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzeNu-0002kg-RC for help-gnu-emacs@gnu.org; Sat, 03 Jul 2021 08:04:36 -0400 Original-Received: from [10.127.215.81] ([::ffff:197.157.0.17]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_CHACHA20_POLY1305) by stw1.rcdrun.com with ESMTPSA id 0000000000057F20.0000000060E0524F.000053EB; Sat, 03 Jul 2021 05:04:30 -0700 In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: 29 X-Spam_score: 2.9 X-Spam_bar: ++ X-Spam_report: (2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL_CSS=3.335, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131436 Archived-At: I appreciate this tip and will test it On July 3, 2021 11:10:47 AM UTC, Yuri Khan w= rote: >On Sat, 3 Jul 2021 at 16:41, Jean Louis wrote: > >> As I am developing Double Opt-In CGI script served by Emacs I am >> unsure if this function is correct to be used the encoded strings >that >> come from URL GET requests, like >http://www=2Eexample=2Ecom/?message=3DHello%20There >> >> (rfc2231-decode-encoded-string "Hello%20there") =E2=87=92 "Hello there" >> >> If anybody knows or have clues, let me know=2E In other programming >> languages I have not been thinking of RFC, I don't know which RFC >> applies there=2E > >Why not look at the RFC referenced in order to see whether it is or is >not relevant to your task? > >https://datatracker=2Eietf=2Eorg/doc/html/rfc2231 > >It talks about encoding MIME headers, which is not what you=E2=80=99re de= aling >with; and its encoded strings look like >'', which is not what you >have=2E > >What you are dealing with is a URL, specifically, its query string >part=2E These are described in RFC 3986, and its percent-encoding scheme >in sections 2=2E1 and 2=2E5=2E > >(url-unhex-string =E2=80=A6) will do half the work for you: It will decod= e >percent-encoded sequences into bytes=2E By convention, in URLs, >characters are UTF-8-encoded before percent-encoding (see RFC 3986 =C2=A7 >2=2E5), so you=E2=80=99ll need to use: > > (decode-coding-string (url-unhex-string s) 'utf-8) > >to get a fully decoded text string=2E Jean