summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Conchillo Flaque <aconchillo@gmail.com>2013-05-02 12:13:31 -0700
committerMark H Weaver <mhw@netris.org>2013-05-02 17:13:55 -0400
commit6fe2803b45fbbd676625c9d665151e5a8a57aca5 (patch)
tree0591ec25ecd8fe2a0f8477ef8b79011cfc5f06d0
parente006d87ba5942b6e49b39b951413dfe63785a398 (diff)
downloadguile-6fe2803b45fbbd676625c9d665151e5a8a57aca5.tar.gz
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." * test-suite/tests/web-uri.test ("encode"): update tests.
-rw-r--r--module/web/uri.scm11
-rw-r--r--test-suite/tests/web-uri.test4
2 files changed, 8 insertions, 7 deletions
diff --git a/module/web/uri.scm b/module/web/uri.scm
index 7fe010096..3ab820d14 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))
diff --git a/test-suite/tests/web-uri.test b/test-suite/tests/web-uri.test
index 3f6e7e3ab..3d14d9d46 100644
--- a/test-suite/tests/web-uri.test
+++ b/test-suite/tests/web-uri.test
@@ -259,5 +259,5 @@
(with-test-prefix "encode"
(pass-if (equal? "foo%20bar" (uri-encode "foo bar")))
- (pass-if (equal? "foo%0a%00bar" (uri-encode "foo\n\x00bar")))
- (pass-if (equal? "%3c%3e%5c%5e" (uri-encode "<>\\^"))))
+ (pass-if (equal? "foo%0A%00bar" (uri-encode "foo\n\x00bar")))
+ (pass-if (equal? "%3C%3E%5C%5E" (uri-encode "<>\\^"))))