Changeset 20510 in project


Ignore:
Timestamp:
09/25/10 19:54:32 (10 years ago)
Author:
sjamaan
Message:

uri-generic: Fix bogus tests that assumed trailing slashes should be normalised away during reference resolution. There's nothing to support that idea in the spec, and all major browsers in fact preserve trailing slashes.

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

Legend:

Unmodified
Added
Removed
  • release/4/uri-generic/trunk/tests/run.scm

    r20468 r20510  
    5353
    5454(define rfc-cases
    55   `((,base "g:h" "g:h")
     55  `(;; Examples from section 5.2.4
     56    ("/a/b/c/" "./../../g" "/a/g")
     57    ("/a/b/c/xyz" "./../../g" "/a/g") ; Input could've had a trailing component
     58    ("mid/content=5/" "../6" "mid/6")
     59    ("mid/content=5/7" "../6" "mid/6") ; Same here
     60
     61    ;; "Normal examples", section 5.4.1
     62    (,base "g:h" "g:h")
    5663    (,base "g" "http://a/b/c/g")
    5764    (,base "./g" "http://a/b/c/g")
     
    7582    (,base "../../" "http://a/")
    7683    (,base "../../g" "http://a/g")
    77     ))
    78 
    79 (define extra-cases
    80   `((,base "" ,base)
     84   
     85    ;; "Abnormal examples", section 5.4.2
     86    (,base "" ,base)
    8187    (,base "../../../g" "http://a/g")
    8288    (,base "../../../../g" "http://a/g")
     
    99105    (,base "g#s/./x" "http://a/b/c/g#s/./x")
    100106    (,base "g#s/../x" "http://a/b/c/g#s/../x")
    101    
    102     ("?a=b&c=d" "" "?a=b&c=d")
     107    ))
     108
     109(define extra-cases
     110  `(("?a=b&c=d" "" "?a=b&c=d")
    103111    (,base "" "http://a/b/c/d;p?q")
    104112    ("" ,base "http://a/b/c/d;p?q")
    105113    (,base "http:" "http:")
    106114    (,base "..%2f" "http://a/b/c/..%2f")
     115    ;; Assume an empty uri-reference is identical to "."
     116    ("http://a/b/c/d/" "" "http://a/b/c/d/")
     117    ("http://a/b/c/d" "" "http://a/b/c/d")
    107118    ("http://a/b/c/d/" ".." "http://a/b/c/")
    108119    ("http://a/b/c/d/" "../e" "http://a/b/c/e")
    109120    ("http://a/b/c/d/" "../e/" "http://a/b/c/e/")
    110     ("http://a/b//c///d///" "..//.." "http://a/b/")
     121    ("http://a/b//c///d///" "../.." "http://a/b//c///d/")
     122    ("http://a/b/c/d/" "..//x" "http://a/b/c//x")
    111123    ("http://a" "b" "http://a/b") ; RFC3986, section 5.2.3, first bullet point
    112124   
     
    130142    (,base "ftp://a/b/c/d;p?q" "ftp://a/b/c/d;p?q")
    131143    (,base "ftp://x/y/z;a?b" "ftp://x/y/z;a?b")))
    132 
    133144
    134145(test-group "uri test"
  • release/4/uri-generic/trunk/uri-generic.scm

    r20509 r20510  
    892892                               ((_ . rst) rst)
    893893                               (else rpb)))))
    894     (append pb1 pr)))
     894    (append pb1 pr))) ; It is assumed we never get here if pr is empty!
    895895
    896896(define (merge-paths b pr)  ; pr is a relative path, *not* a URI object
     
    910910
    911911(define (elim-dots ps)
    912   (let loop ((ps ps) (lst (list)))
    913     (if (null? ps) (reverse lst)
     912  (let loop ((ps ps) (trailing-slash? #f) (lst (list)))
     913    (if (null? ps) (reverse (if trailing-slash? (cons "" lst) lst))
    914914        (match ps
    915915               (("." . rst)
    916                 (loop rst (match lst
    917                                  (("" dir . rest) lst)
    918                                  ((file . rest) (cons "" lst))
    919                                  (else (list "")))))
     916                (loop rst #t lst))
    920917               ((".." . rst)
    921                 (loop rst (match lst
    922                                  (("" dir . rest) (cons "" rest))
    923                                  ((file . rest) (cons "" rest))
    924                                  (else (list "")))))
    925                (("")
    926                 (loop (list) (match lst
    927                                     (("" . rst2) lst)
    928                                     (else (cons "" lst)))))
     918                (loop rst #t (if (pair? lst) (cdr lst) lst)))
    929919               ((x . rst)
    930                 (loop rst (match lst
    931                                  (("" . rst2) (cons x rst2))
    932                                  (else (cons x lst)))))))))
     920                (loop rst #f (cons x lst)))))))
    933921
    934922;;
     
    960948                     authority: #f
    961949                     path: (rel-path-from
    962                             (remove-body-dot-segments (uri-path uabs))
    963                             (remove-body-dot-segments (uri-path base)))))
     950                            (remove-dot-segments (uri-path uabs))
     951                            (remove-dot-segments (uri-path base)))))
    964952        ((ucdiff? uri-query uabs base)
    965953         (update-URI uabs
     
    982970               ((and (string? s1) (string? s2))   (string=? s1 s2))
    983971               (else                              (eq? s1 s2))))))
    984 
    985 (define (remove-body-dot-segments p)
    986   (match p
    987          (('/ segs ... last)
    988           (cons '/ (reverse (cons last (remove-dot-segments (reverse segs))))))
    989          ((segs ... last)
    990           (reverse (cons last (remove-dot-segments (reverse segs)))))
    991          (else p)))
    992972
    993973(define (rel-path-from pabs base)
Note: See TracChangeset for help on using the changeset viewer.