unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase
@ 2013-05-02 17:44 Aleix Conchillo Flaqué
  2013-05-02 18:53 ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: Aleix Conchillo Flaqué @ 2013-05-02 17:44 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

This patch changes the way uri-encode does percent-encoding. The
hexadecimal characters are now uppercase as suggested by RFC3986. So,

(uri-encode "/")
=> %2F

Aleix

[-- Attachment #2: uri-encode-uppercase.patch --]
[-- Type: application/octet-stream, Size: 2885 bytes --]

From 9909cae88e9bdf03b4253170a8669e5eb667b2b6 Mon Sep 17 00:00:00 2001
From: Aleix Conchillo Flaque <aconchillo@gmail.com>
Date: Thu, 2 May 2013 10:39:18 -0700
Subject: [PATCH] web: uri-encode hexadecimal percent-encoding is now
 uppercase

* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH
  is now uppercased as suggested by RFC3986:

      "For consistency, URI producers and normalizers should use
       uppercase hexadecimal digits for all percent-encodings."
---
 module/web/uri.scm |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/module/web/uri.scm b/module/web/uri.scm
index 7fe0100..df5a792 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -6,12 +6,12 @@
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
 ;;;; version 3 of the License, or (at your option) any later version.
-;;;; 
+;;;;
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ;;;; Lesser General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU Lesser General Public
 ;;;; License along with this library; if not, write to the Free Software
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -20,7 +20,7 @@
 ;;; Commentary:
 
 ;; A data type for Universal Resource Identifiers, as defined in RFC
-;; 3986. 
+;; 3986.
 
 ;;; Code:
 
@@ -382,7 +382,7 @@ The default character set includes alphanumerics from ASCII, as well as
 the special characters ‘-’, ‘.’, ‘_’, and ‘~’.  Any other character will
 be percent-encoded, by writing out the character to a bytevector within
 the given ENCODING, then encoding each byte as ‘%HH’, where HH is the
-hexadecimal representation of the byte."
+uppercase hexadecimal representation of the byte."
   (define (needs-escaped? ch)
     (not (char-set-contains? unescaped-chars ch)))
   (if (string-index str needs-escaped?)
@@ -396,11 +396,12 @@ hexadecimal representation of the byte."
                        (len (bytevector-length bv)))
                   (let lp ((i 0))
                     (if (< i len)
-                        (let ((byte (bytevector-u8-ref bv i)))
+                        (let* ((byte (bytevector-u8-ref bv i))
+                               (num (number->string byte 16)))
                           (display #\% port)
                           (when (< byte 16)
                             (display #\0 port))
-                          (display (number->string byte 16) port)
+                          (display (string-upcase num) port)
                           (lp (1+ i))))))))
           str)))
       str))
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase
  2013-05-02 17:44 [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase Aleix Conchillo Flaqué
@ 2013-05-02 18:53 ` Mark H Weaver
  2013-05-02 19:15   ` Aleix Conchillo Flaqué
  0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2013-05-02 18:53 UTC (permalink / raw)
  To: Aleix Conchillo Flaqué; +Cc: guile-devel

Hi Aleix,

This patch looks good to me, except that I don't like the variable name
'num' for a string.  Actually, I'm not sure we need to bind that to a
variable at all.  How about just wrapping 'string-upcase' around the
call to 'number->string'?

      Thanks,
        Mark


> @@ -396,11 +396,12 @@ hexadecimal representation of the byte."
>                         (len (bytevector-length bv)))
>                    (let lp ((i 0))
>                      (if (< i len)
> -                        (let ((byte (bytevector-u8-ref bv i)))
> +                        (let* ((byte (bytevector-u8-ref bv i))
> +                               (num (number->string byte 16)))
>                            (display #\% port)
>                            (when (< byte 16)
>                              (display #\0 port))
> -                          (display (number->string byte 16) port)
> +                          (display (string-upcase num) port)
>                            (lp (1+ i))))))))
>            str)))
>        str))



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase
  2013-05-02 18:53 ` Mark H Weaver
@ 2013-05-02 19:15   ` Aleix Conchillo Flaqué
  2013-05-02 21:17     ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: Aleix Conchillo Flaqué @ 2013-05-02 19:15 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 373 bytes --]

On Thu, May 2, 2013 at 11:53 AM, Mark H Weaver <mhw@netris.org> wrote:
> Hi Aleix,
>
> This patch looks good to me, except that I don't like the variable name
> 'num' for a string.  Actually, I'm not sure we need to bind that to a
> variable at all.  How about just wrapping 'string-upcase' around the
> call to 'number->string'?
>

Makes sense. Let's see this one.

Aleix

[-- Attachment #2: uri-encode-uppercase.patch --]
[-- Type: application/octet-stream, Size: 2622 bytes --]

From 8f1d8b7f4c08d81c44884697e9fed717be27e857 Mon Sep 17 00:00:00 2001
From: Aleix Conchillo Flaque <aconchillo@gmail.com>
Date: Thu, 2 May 2013 12:13:31 -0700
Subject: [PATCH] web: uri-encode hexadecimal percent-encoding is now
 uppercase

* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH
  is now uppercased as suggested by RFC3986:

      "For consistency, URI producers and normalizers should use
       uppercase hexadecimal digits for all percent-encodings."
---
 module/web/uri.scm |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/module/web/uri.scm b/module/web/uri.scm
index 7fe0100..3ab820d 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -6,12 +6,12 @@
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
 ;;;; version 3 of the License, or (at your option) any later version.
-;;;; 
+;;;;
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ;;;; Lesser General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU Lesser General Public
 ;;;; License along with this library; if not, write to the Free Software
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -20,7 +20,7 @@
 ;;; Commentary:
 
 ;; A data type for Universal Resource Identifiers, as defined in RFC
-;; 3986. 
+;; 3986.
 
 ;;; Code:
 
@@ -382,7 +382,7 @@ The default character set includes alphanumerics from ASCII, as well as
 the special characters ‘-’, ‘.’, ‘_’, and ‘~’.  Any other character will
 be percent-encoded, by writing out the character to a bytevector within
 the given ENCODING, then encoding each byte as ‘%HH’, where HH is the
-hexadecimal representation of the byte."
+uppercase hexadecimal representation of the byte."
   (define (needs-escaped? ch)
     (not (char-set-contains? unescaped-chars ch)))
   (if (string-index str needs-escaped?)
@@ -400,7 +400,8 @@ hexadecimal representation of the byte."
                           (display #\% port)
                           (when (< byte 16)
                             (display #\0 port))
-                          (display (number->string byte 16) port)
+                          (display (string-upcase (number->string byte 16))
+                                   port)
                           (lp (1+ i))))))))
           str)))
       str))
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase
  2013-05-02 19:15   ` Aleix Conchillo Flaqué
@ 2013-05-02 21:17     ` Mark H Weaver
  2013-05-02 23:50       ` Aleix Conchillo Flaqué
  0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2013-05-02 21:17 UTC (permalink / raw)
  To: Aleix Conchillo Flaqué; +Cc: guile-devel

Hi Aleix,

There was one remaining problem with your commit: web-uri.test contained
some tests that assumed lowercase percent encoding.  I took the liberty
of modifying your commit to fix those tests, and then pushed it to
stable-2.0.

     Thanks!
       Mark



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase
  2013-05-02 21:17     ` Mark H Weaver
@ 2013-05-02 23:50       ` Aleix Conchillo Flaqué
  0 siblings, 0 replies; 5+ messages in thread
From: Aleix Conchillo Flaqué @ 2013-05-02 23:50 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guile-devel

On Thu, May 2, 2013 at 2:17 PM, Mark H Weaver <mhw@netris.org> wrote:
> Hi Aleix,
>
> There was one remaining problem with your commit: web-uri.test contained
> some tests that assumed lowercase percent encoding.  I took the liberty
> of modifying your commit to fix those tests, and then pushed it to
> stable-2.0.
>

Oh... right :-(. Have to get used to the process.

Thanks!

Aleix



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-02 23:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-02 17:44 [PATCH] web: uri-encode hexadecimal percent-encoding is now uppercase Aleix Conchillo Flaqué
2013-05-02 18:53 ` Mark H Weaver
2013-05-02 19:15   ` Aleix Conchillo Flaqué
2013-05-02 21:17     ` Mark H Weaver
2013-05-02 23:50       ` Aleix Conchillo Flaqué

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).