From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#24694: Document url--allow-chars for external use? Date: Sat, 12 Oct 2019 11:23:48 -0700 Message-ID: <3e23aa8b-248b-8416-206e-eadff0d75a31@topbug.net> References: <8337jy4uv3.fsf@gnu.org> <87oa0vtk3y.fsf@topbug.net> <7137f36f-983f-2e78-ebdc-4b2e277410a1@topbug.net> <83r23jpidw.fsf@gnu.org> <6b6be3c2-9e52-7899-df83-d82611029aee@topbug.net> <835zkunx9o.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4BF361A623307A72F5A9A623" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="172432"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: 24694@debbugs.gnu.org, rpluim@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 12 20:40:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iJMJI-000ijv-AD for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Oct 2019 20:40:12 +0200 Original-Received: from localhost ([::1]:35414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJMJG-0001dv-QW for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Oct 2019 14:40:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJMJA-0001dd-6z for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2019 14:40:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJMJ8-0003x5-SY for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2019 14:40:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53523) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJMJ8-0003wT-MU for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2019 14:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iJMJ8-000300-H0 for bug-gnu-emacs@gnu.org; Sat, 12 Oct 2019 14:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Oct 2019 18:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24694 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24694-submit@debbugs.gnu.org id=B24694.157090554511451 (code B ref 24694); Sat, 12 Oct 2019 18:40:02 +0000 Original-Received: (at 24694) by debbugs.gnu.org; 12 Oct 2019 18:39:05 +0000 Original-Received: from localhost ([127.0.0.1]:34111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iJMIC-0002yc-Uq for submit@debbugs.gnu.org; Sat, 12 Oct 2019 14:39:05 -0400 Original-Received: from sender4-of-o54.zoho.com ([136.143.188.54]:21473) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iJMI9-0002yC-WB for 24694@debbugs.gnu.org; Sat, 12 Oct 2019 14:39:03 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1570904631; cv=none; d=zoho.com; s=zohoarc; b=Q61N8sNqwUVI3tG0am3T8TmbbGVf++BhDW6jGGUq8u0Xalg7mV6Scz5lkvbipFh6XquAZ+rPzM2NocFT6x4KfWaApiaLpRPfele/5higkL8JBN/Zk+keB7RE2GuWP/ecOt2JnyBrbMSud11Z3XxNIgNc6WwS4Qq8jeAwmn0Nd1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570904631; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=dtwjQNyImmJHDzqiF0G9ybaVQVOy3sC1eA5LdPkiAbE=; b=KugGef5SXijs5SmZTTnX1qjGbmbsHqJQFiGUV2hfY2fg97Tt6rOmq0p81nGVrXgHV+9hvnQ/cb9UFJooj58N4iv9QU9KbKJh6/vdiebubevVbmLAycLkOxHrgTUI+PmlXefR3RJSlGiBRPtAFKKlRPQahTX82fjzb7FC5QH+eRU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=topbug.net; spf=pass smtp.mailfrom=hong@topbug.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1570904631; s=zoho; d=topbug.net; i=hong@topbug.net; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type; l=4310; bh=dtwjQNyImmJHDzqiF0G9ybaVQVOy3sC1eA5LdPkiAbE=; b=b8svijaXcBVtr+MB6LcQlEp1qObJCCsRWzBu6UMebKiuV27aenpCgUGSZfjq7Bpd hWX8FblVjEO3ifMieN98EhCe2M84zotNbm0P25PsQA0PelG/IGg0hde3AK4NaQQIydt 2XnjqSYKOiMp4x7rNx2zCSZl5fX0H+xeWPDMQvUI= Original-Received: from [192.168.88.88] (69-215-149-151.lightspeed.sntcca.sbcglobal.net [69.215.149.151]) by mx.zohomail.com with SMTPS id 1570904629087924.3103497271802; Sat, 12 Oct 2019 11:23:49 -0700 (PDT) Openpgp: preference=signencrypt In-Reply-To: <835zkunx9o.fsf@gnu.org> Content-Language: en-US X-Zoho-Virus-Status: 1 X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:169046 Archived-At: This is a multi-part message in MIME format. --------------4BF361A623307A72F5A9A623 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/12/19 2:11 AM, Eli Zaretskii wrote: > > I have a couple of minor comments: I've attached an update. > > The log message should specify each file with leading directories > starting from the root of the Emacs tree. E.g., url-util.el should be > shown as lisp/url/url-util.el. Done. > > Also, please always mention the bug number in the log message. Done. > >> +allowed characters. Otherwise, ALLOWED-CHARS should be either a >> +vector whose Nth element is non-nil if character N is allowed or >> +a list of allowed chars. ^ > > Please insert a comma where indicated, it will make the sentence > easier to read. I swapped the two choices (the shorter one goes first) and hopefully this will be easier to read. Also updated the doc in url.texi. --------------4BF361A623307A72F5A9A623 Content-Type: text/x-patch; name="0001-Make-url-hexify-string-accept-a-list-of-allowed-char.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Make-url-hexify-string-accept-a-list-of-allowed-char.pa"; filename*1="tch" >From 01bb6f74a4e91534a253bffab0457a27f6cb6111 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Fri, 11 Oct 2019 19:17:23 -0700 Subject: [PATCH] Make url-hexify-string accept a list of allowed chars (bug#26469) * lisp/url/url-util.el (url-hexify-string): Accept a list of allowed chars. * doc/misc/url.texi (URI Encoding): Update url-hexify-string doc and index improvements. --- doc/misc/url.texi | 8 ++++++-- lisp/url/url-util.el | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/misc/url.texi b/doc/misc/url.texi index e72d9bfe3d2e..79dead185dd0 100644 --- a/doc/misc/url.texi +++ b/doc/misc/url.texi @@ -221,6 +221,7 @@ URI Encoding @section URI Encoding @cindex percent encoding +@findex url-generic-parse-url The @code{url-generic-parse-url} parser does not obey RFC 3986 in one respect: it allows non-@acronym{ASCII} characters in URI strings. @@ -233,6 +234,7 @@ URI Encoding @acronym{ASCII} characters must also be percent encoded when they appear in URI components.) +@findex url-encode-url The function @code{url-encode-url} can be used to convert a URI string containing arbitrary characters to one that is properly percent-encoded in accordance with RFC 3986. @@ -244,6 +246,8 @@ URI Encoding previously uppercase. @end defun +@findex url-hexify-string +@findex url-unhex-string To convert between a string containing arbitrary characters and a percent-encoded all-@acronym{ASCII} string, use the functions @code{url-hexify-string} and @code{url-unhex-string}: @@ -263,8 +267,8 @@ URI Encoding argument is @code{nil}, the allowed characters are those specified as @dfn{unreserved characters} by RFC 3986 (see the variable @code{url-unreserved-chars}). Otherwise, @var{allowed-chars} should -be a vector whose @var{n}-th element is non-@code{nil} if character -@var{n} is allowed. +be either a list of allowed chars, or a vector whose Nth element is +non-nil if character N is allowed. @end defun @defun url-unhex-string string &optional allow-newlines diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index a390723e73dc..e5b09d5a29db 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el @@ -395,9 +395,13 @@ url-hexify-string The allowed characters are specified by ALLOWED-CHARS. If this argument is nil, the list `url-unreserved-chars' determines the -allowed characters. Otherwise, ALLOWED-CHARS should be a vector -whose Nth element is non-nil if character N is allowed." - (unless allowed-chars +allowed characters. Otherwise, ALLOWED-CHARS should be either a +list of allowed chars, or a vector whose Nth element is non-nil +if character N is allowed. +" + (if allowed-chars + (unless (vectorp allowed-chars) + (setq allowed-chars (url--allowed-chars allowed-chars))) (setq allowed-chars (url--allowed-chars url-unreserved-chars))) (mapconcat (lambda (byte) (if (aref allowed-chars byte) -- 2.20.1 --------------4BF361A623307A72F5A9A623--