From 7960648a3b7cff1d4f0ea2b2a5569e910c95bf91 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Fri, 2 Apr 2010 16:55:14 -0400 Subject: [PATCH] Completed support for http://www.ietf.org/rfc/rfc2396.txt 2.4.3 by adding special case for control code 7F. Had to increase the bit-vector length to 128, and added #\Rubout (#x7F) to *excluded-characters*. Added a docstring and test. --- src.lisp | 8 +++++--- tests.lisp | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src.lisp b/src.lisp index d39d32b..44ec5ea 100644 --- a/src.lisp +++ b/src.lisp @@ -356,16 +356,18 @@ (defparameter *excluded-characters* (append + ;; exclude control characters (loop for i from 0 to #x1f collect (code-char i)) '(;; `delims' (except #\%, because it's handled specially): #\< #\> #\" #\space #\# - + #\Rubout ;; (code-char #x7f) ;; `unwise': - #\{ #\} #\| #\\ #\^ #\[ #\] #\`))) + #\{ #\} #\| #\\ #\^ #\[ #\] #\`)) + "Excluded charcters from RFC2369 (http://www.ietf.org/rfc/rfc2396.txt 2.4.3)") (defun reserved-char-vector (chars &key except) - (do* ((a (make-array 127 :element-type 'bit :initial-element 0)) + (do* ((a (make-array 128 :element-type 'bit :initial-element 0)) (chars chars (cdr chars)) (c (car chars) (car chars))) ((null chars) a) diff --git a/tests.lisp b/tests.lisp index 77d1961..0344922 100644 --- a/tests.lisp +++ b/tests.lisp @@ -408,15 +408,17 @@ :condition-type 'uri-parse-error) res) - - ;;an escaped newline isn't rendered properly - (push - `(let ((weird-uri "https://example.com/q?foo%0abar%20baz")) - (test - weird-uri - (puri:render-uri (puri:parse-uri weird-uri) nil) - :test #'string=) - ) res) + ;;; tests for weird control characters + ;; http://www.ietf.org/rfc/rfc2396.txt 2.4.3 + (dolist (x '("https://example.com/q?foo%0abar%20baz" ;;an escaped newline + "https://example.com/q?%7f" ;; 7f, 127 + )) + (push + `(let ((weird-uri ,x)) + (test weird-uri + (puri:render-uri (puri:parse-uri weird-uri) nil) + :test #'string=) + ) res)) `(progn ,@(nreverse res)))) -- 1.7.10.4