Changeset 12909 in project


Ignore:
Timestamp:
12/28/08 21:08:43 (11 years ago)
Author:
sjamaan
Message:

Merge changes from release 4

Location:
release/3/uri-generic/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/uri-generic/trunk

  • release/3/uri-generic/trunk/uri-generic.scm

    r12858 r12909  
    6161         uri-relative-to uri-relative-from
    6262         uri-decode-string uri-encode-string
    63          uri-normalize-case uri-normalize-path-segments))
     63         uri-normalize-case uri-normalize-path-segments
     64         char-set:gen-delims char-set:sub-delims
     65         char-set:uri-reserved char-set:uri-unreserved))
    6466
    6567(cond-expand
     
    147149(define (hexdigit-char? c)    (and (char? c) (char-set-contains? char-set:hex-digit c)))
    148150
    149 (define (reserved-char? c)    (and (char? c) (char-set-contains? char-set:reserved c)))
    150 
    151 (define (unreserved-char? c)  (and (char? c) (char-set-contains? char-set:unreserved c)))
     151(define (reserved-char? c)    (and (char? c) (char-set-contains? char-set:uri-reserved c)))
     152
     153(define (unreserved-char? c)  (and (char? c) (char-set-contains? char-set:uri-unreserved c)))
    152154
    153155(define (scheme-char? c)      (and (char? c) (char-set-contains? char-set:scheme c)))
     
    243245;; Returns a 'pct-encoded' sequence of octets.
    244246;;
    245 (define (pct-encode char-list #!optional (char-set char-set:unreserved))
     247(define (pct-encode char-list char-set)
    246248  (define (hex-digit i)
    247249    (and (>= i 0) (< i 16) (car (string->list (sprintf "~X" i)))))
     
    257259;; Inverse operation: 'pct-decode' a sequence of octets.
    258260
    259 (define (pct-decode char-list #!optional (char-set char-set:unreserved))
     261(define (pct-decode char-list char-set)
    260262  (define (octet-decode h1 h2)
    261263    (string->number (list->string (list h1 h2)) 16))
     
    276278(define char-set:sub-delims (string->char-set "!$&'()*+,;="))
    277279
    278 (define char-set:reserved (char-set-union char-set:gen-delims char-set:sub-delims))
     280(define char-set:uri-reserved (char-set-union char-set:gen-delims char-set:sub-delims))
    279281
    280282;;  RFC3986, section 2.3
     
    283285;;
    284286
    285 (define char-set:unreserved
     287(define char-set:uri-unreserved
    286288  (char-set-union char-set:letter+digit (string->char-set "-_.~")))
    287289
     
    312314
    313315(define (uri-path-list->path pcl)
    314   (let ((cs (char-set-union char-set:unreserved (char-set #\/))))
     316  (let ((cs (char-set-union char-set:uri-unreserved (char-set #\/))))
    315317    (match pcl
    316318           (('/ . rst) (cons '/ (map (compose uri-char-list->string (cute pct-decode <> cs)) rst)))
     
    403405
    404406(define char-set:ipv-future
    405   (char-set-union char-set:unreserved char-set:sub-delims (char-set #\;)))
     407  (char-set-union char-set:uri-unreserved char-set:sub-delims (char-set #\;)))
    406408
    407409
     
    786788;;  Percent encoding and decoding
    787789
    788 (define (uri-encode-string str)
     790(define (uri-encode-string str #!optional (char-set (char-set-union
     791                                                     (char-set #\%)
     792                                                     char-set:uri-reserved)))
    789793  (let ((clst (string->list str)))
    790794    (uri-char-list->string
    791      (pct-encode clst (char-set-union (char-set #\%) char-set:reserved)))))
    792 
    793 (define (uri-decode-string str)
    794   (uri-char-list->string (pct-decode (uri-string->char-list str) char-set:full)))
     795     (pct-encode clst char-set))))
     796
     797(define (uri-decode-string str #!optional (char-set char-set:full))
     798  (uri-char-list->string (pct-decode (uri-string->char-list str) char-set)))
    795799   
    796800(define (uri-string->normalized-char-list str)
    797   (pct-decode (uri-string->char-list str)))
     801  (pct-decode (uri-string->char-list str) char-set:uri-unreserved))
    798802
    799803
Note: See TracChangeset for help on using the changeset viewer.