* bug#24694: Document url--allow-chars for external use?
@ 2016-10-14 18:24 Hong Xu
2016-10-14 19:02 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Hong Xu @ 2016-10-14 18:24 UTC (permalink / raw)
To: 24694
[-- Attachment #1.1: Type: text/plain, Size: 515 bytes --]
Currently url-hexify-string has an optional argument allowed-chars,
which is a long vector. However, it is more natural to specify a list of
characters. Internally, the default value of allowed-chars is specified
by converting a list of chars to such a vector by using an internal
function url--allow-chars. I would like to suggest to document
url--allow-chars for external use, thus we can improve the interface of
the url-hexify-string function.
I can draft the document change, if you agree with me.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2016-10-14 18:24 bug#24694: Document url--allow-chars for external use? Hong Xu
@ 2016-10-14 19:02 ` Eli Zaretskii
2016-10-14 19:36 ` Hong Xu
2016-12-01 21:28 ` Hong Xu
0 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2016-10-14 19:02 UTC (permalink / raw)
To: Hong Xu; +Cc: 24694
> From: Hong Xu <hong@topbug.net>
> Date: Fri, 14 Oct 2016 11:24:52 -0700
>
> Currently url-hexify-string has an optional argument allowed-chars,
> which is a long vector. However, it is more natural to specify a list of
> characters. Internally, the default value of allowed-chars is specified
> by converting a list of chars to such a vector by using an internal
> function url--allow-chars. I would like to suggest to document
> url--allow-chars for external use, thus we can improve the interface of
> the url-hexify-string function.
>
> I can draft the document change, if you agree with me.
Isn't it better to teach url-hexify-string to accept lists as well?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2016-10-14 19:02 ` Eli Zaretskii
@ 2016-10-14 19:36 ` Hong Xu
2016-12-01 21:28 ` Hong Xu
1 sibling, 0 replies; 11+ messages in thread
From: Hong Xu @ 2016-10-14 19:36 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 24694
[-- Attachment #1.1: Type: text/plain, Size: 781 bytes --]
On 10/14/2016 12:02 PM, Eli Zaretskii wrote:
>> From: Hong Xu <hong@topbug.net>
>> Date: Fri, 14 Oct 2016 11:24:52 -0700
>>
>> Currently url-hexify-string has an optional argument allowed-chars,
>> which is a long vector. However, it is more natural to specify a list of
>> characters. Internally, the default value of allowed-chars is specified
>> by converting a list of chars to such a vector by using an internal
>> function url--allow-chars. I would like to suggest to document
>> url--allow-chars for external use, thus we can improve the interface of
>> the url-hexify-string function.
>>
>> I can draft the document change, if you agree with me.
>
> Isn't it better to teach url-hexify-string to accept lists as well?
>
Yes, that would be even better.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2016-10-14 19:02 ` Eli Zaretskii
2016-10-14 19:36 ` Hong Xu
@ 2016-12-01 21:28 ` Hong Xu
2019-10-04 19:31 ` Hong Xu
1 sibling, 1 reply; 11+ messages in thread
From: Hong Xu @ 2016-12-01 21:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 24694
[-- Attachment #1.1: Type: text/plain, Size: 1011 bytes --]
On 2016-10-14 Fri 12:02 GMT-0800, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Hong Xu <hong@topbug.net>
>> Date: Fri, 14 Oct 2016 11:24:52 -0700
>>
>> Currently url-hexify-string has an optional argument allowed-chars,
>> which is a long vector. However, it is more natural to specify a list of
>> characters. Internally, the default value of allowed-chars is specified
>> by converting a list of chars to such a vector by using an internal
>> function url--allow-chars. I would like to suggest to document
>> url--allow-chars for external use, thus we can improve the interface of
>> the url-hexify-string function.
>>
>> I can draft the document change, if you agree with me.
>
> Isn't it better to teach url-hexify-string to accept lists as well?
The patch is attached.
Make url-hexify-string accept a list of allowed chars.
* url-util.el (url-hexify-string): Accept a list of allowed chars.
* url.texi (URI Encoding): Update url-hexify-string doc and index improvements.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: url.patch --]
[-- Type: text/x-diff, Size: 2791 bytes --]
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index 91cb6b54a847..b5e6e2ce465a 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,11 +246,13 @@ 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}:
-@defun url-hexify-string string &optional allowed-chars
+@defun url-hexify-string string &optional allowed-chars list-chars
This function performs percent-encoding on @var{string}, and returns
the result.
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index 1ae2213eee65..96fc741a1700 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -398,18 +398,23 @@ url--allowed-chars
vec))
;;;###autoload
-(defun url-hexify-string (string &optional allowed-chars)
+(defun url-hexify-string (string &optional allowed-chars list-chars)
"URI-encode STRING and return the result.
If STRING is multibyte, it is first converted to a utf-8 byte
string. Each byte corresponding to an allowed character is left
as-is, while all other bytes are converted to a three-character
string: \"%\" followed by two upper-case hex digits.
-The allowed characters are specified by ALLOWED-CHARS. If this
+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, if LIST-CHARS is nil or omitted,
+ALLOWED-CHARS should be a vector whose Nth element is non-nil if
+character N is allowed; if LIST-CHARS is non-nil, ALLOWED-CHARS
+should be a list of allowed chars.
+"
+ (if allowed-chars
+ (when list-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)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2016-12-01 21:28 ` Hong Xu
@ 2019-10-04 19:31 ` Hong Xu
2019-10-11 12:38 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Hong Xu @ 2019-10-04 19:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 24694
On 12/1/16 1:28 PM, Hong Xu wrote:
>
> On 2016-10-14 Fri 12:02 GMT-0800, Eli Zaretskii <eliz@gnu.org> wrote:
>
>>> From: Hong Xu <hong@topbug.net>
>>> Date: Fri, 14 Oct 2016 11:24:52 -0700
>>>
>>> Currently url-hexify-string has an optional argument allowed-chars,
>>> which is a long vector. However, it is more natural to specify a list of
>>> characters. Internally, the default value of allowed-chars is specified
>>> by converting a list of chars to such a vector by using an internal
>>> function url--allow-chars. I would like to suggest to document
>>> url--allow-chars for external use, thus we can improve the interface of
>>> the url-hexify-string function.
>>>
>>> I can draft the document change, if you agree with me.
>>
>> Isn't it better to teach url-hexify-string to accept lists as well?
>
> The patch is attached.
>
> Make url-hexify-string accept a list of allowed chars.
>
> * url-util.el (url-hexify-string): Accept a list of allowed chars.
> * url.texi (URI Encoding): Update url-hexify-string doc and index improvements.
>
It's been a few years... I'm wondering whether this patch is still interesting?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-04 19:31 ` Hong Xu
@ 2019-10-11 12:38 ` Eli Zaretskii
2019-10-11 14:32 ` Robert Pluim
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-11 12:38 UTC (permalink / raw)
To: Hong Xu; +Cc: 24694
> From: Hong Xu <hong@topbug.net>
> Cc: 24694@debbugs.gnu.org
> Date: Fri, 4 Oct 2019 12:31:27 -0700
>
> > Make url-hexify-string accept a list of allowed chars.
> >
> > * url-util.el (url-hexify-string): Accept a list of allowed chars.
> > * url.texi (URI Encoding): Update url-hexify-string doc and index improvements.
> >
>
> It's been a few years... I'm wondering whether this patch is still interesting?
I think it is, yes. Can you send a patch relative to the current
master branch?
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-11 12:38 ` Eli Zaretskii
@ 2019-10-11 14:32 ` Robert Pluim
2019-10-12 2:21 ` Hong Xu
0 siblings, 1 reply; 11+ messages in thread
From: Robert Pluim @ 2019-10-11 14:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 24694, Hong Xu
>>>>> On Fri, 11 Oct 2019 15:38:03 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> From: Hong Xu <hong@topbug.net>
>> Cc: 24694@debbugs.gnu.org
>> Date: Fri, 4 Oct 2019 12:31:27 -0700
>>
>> > Make url-hexify-string accept a list of allowed chars.
>> >
>> > * url-util.el (url-hexify-string): Accept a list of allowed chars.
>> > * url.texi (URI Encoding): Update url-hexify-string doc and index improvements.
>> >
>>
>> It's been a few years... I'm wondering whether this patch is still interesting?
Eli> I think it is, yes. Can you send a patch relative to the current
Eli> master branch?
Api nit: if the first argument is going to be a list or a vector, you
could just keep one argument and check 'vectorp'.
Robert
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-11 14:32 ` Robert Pluim
@ 2019-10-12 2:21 ` Hong Xu
2019-10-12 9:11 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Hong Xu @ 2019-10-12 2:21 UTC (permalink / raw)
To: Robert Pluim, Eli Zaretskii; +Cc: 24694
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
On 10/11/19 7:32 AM, Robert Pluim wrote:
>>>>>> On Fri, 11 Oct 2019 15:38:03 +0300, Eli Zaretskii <eliz@gnu.org> said:
>
> >> From: Hong Xu <hong@topbug.net>
> >> Cc: 24694@debbugs.gnu.org
> >> Date: Fri, 4 Oct 2019 12:31:27 -0700
> >>
> >> > Make url-hexify-string accept a list of allowed chars.
> >> >
> >> > * url-util.el (url-hexify-string): Accept a list of allowed chars.
> >> > * url.texi (URI Encoding): Update url-hexify-string doc and index improvements.
> >> >
> >>
> >> It's been a few years... I'm wondering whether this patch is still interesting?
>
> Eli> I think it is, yes. Can you send a patch relative to the current
> Eli> master branch?
>
> Api nit: if the first argument is going to be a list or a vector, you
> could just keep one argument and check 'vectorp'.
>
Thanks, I've updated the patch as attached.
[-- Attachment #2: 0001-Make-url-hexify-string-accept-a-list-of-allowed-char.patch --]
[-- Type: text/x-patch, Size: 2431 bytes --]
From 4f56c4081f44ab04e3095b5f3b5332d5c3eb1cdf Mon Sep 17 00:00:00 2001
From: Hong Xu <hong@topbug.net>
Date: Fri, 11 Oct 2019 19:17:23 -0700
Subject: [PATCH] Make url-hexify-string accept a list of allowed chars.
* url-util.el (url-hexify-string): Accept a list of allowed chars.
* url.texi (URI Encoding): Update url-hexify-string doc and index
improvements.
---
doc/misc/url.texi | 4 ++++
lisp/url/url-util.el | 10 +++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index e72d9bfe3d2e..ff6c547bec1e 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}:
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index a390723e73dc..7abd5c216eeb 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
+vector whose Nth element is non-nil if character N is allowed or
+a list of allowed chars.
+"
+ (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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-12 2:21 ` Hong Xu
@ 2019-10-12 9:11 ` Eli Zaretskii
2019-10-12 18:23 ` Hong Xu
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-12 9:11 UTC (permalink / raw)
To: Hong Xu; +Cc: 24694, rpluim
> Cc: 24694@debbugs.gnu.org
> From: Hong Xu <hong@topbug.net>
> Date: Fri, 11 Oct 2019 19:21:34 -0700
>
> Thanks, I've updated the patch as attached.
I have a couple of minor comments:
> * url-util.el (url-hexify-string): Accept a list of allowed chars.
> * url.texi (URI Encoding): Update url-hexify-string doc and index
> improvements.
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.
Also, please always mention the bug number in the log message.
These and other stylistic issues are described in detail in
CONTRIBUTE.
> +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.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-12 9:11 ` Eli Zaretskii
@ 2019-10-12 18:23 ` Hong Xu
2019-10-14 4:47 ` Lars Ingebrigtsen
0 siblings, 1 reply; 11+ messages in thread
From: Hong Xu @ 2019-10-12 18:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 24694, rpluim
[-- Attachment #1: Type: text/plain, Size: 800 bytes --]
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.
[-- Attachment #2: 0001-Make-url-hexify-string-accept-a-list-of-allowed-char.patch --]
[-- Type: text/x-patch, Size: 2965 bytes --]
From 01bb6f74a4e91534a253bffab0457a27f6cb6111 Mon Sep 17 00:00:00 2001
From: Hong Xu <hong@topbug.net>
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#24694: Document url--allow-chars for external use?
2019-10-12 18:23 ` Hong Xu
@ 2019-10-14 4:47 ` Lars Ingebrigtsen
0 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-14 4:47 UTC (permalink / raw)
To: Hong Xu; +Cc: 24694, rpluim
Hong Xu <hong@topbug.net> writes:
>> I have a couple of minor comments:
>
> I've attached an update.
Thanks; applied to the trunk now.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-10-14 4:47 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-14 18:24 bug#24694: Document url--allow-chars for external use? Hong Xu
2016-10-14 19:02 ` Eli Zaretskii
2016-10-14 19:36 ` Hong Xu
2016-12-01 21:28 ` Hong Xu
2019-10-04 19:31 ` Hong Xu
2019-10-11 12:38 ` Eli Zaretskii
2019-10-11 14:32 ` Robert Pluim
2019-10-12 2:21 ` Hong Xu
2019-10-12 9:11 ` Eli Zaretskii
2019-10-12 18:23 ` Hong Xu
2019-10-14 4:47 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.