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

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