Changeset 15327 in project


Ignore:
Timestamp:
08/05/09 19:40:36 (10 years ago)
Author:
sjamaan
Message:

Add exception for URIs: those will probably never be quoted (but we should test with other special chars like quotes)

Location:
release/4/intarweb/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/intarweb/trunk/header-parsers.scm

    r15162 r15327  
    559559
    560560;; Unparse a value as token, converting it to a string first
    561 (define unparse-token
    562   (let* ((trigger-quoting-chars (char-set-union
    563                                  (char-set-adjoin must-be-quoted-chars #\, #\; #\=)
    564                                  char-set:blank)))
    565    (lambda (token)
    566      (let ((token-string (->string token)))
    567       (if (string-any trigger-quoting-chars token-string)
    568           (quote-string token-string)
    569           token-string)))))
     561(define (unparse-token token #!optional (separator-chars (char-set #\= #\; #\,)))
     562  (let ((trigger-quoting-chars
     563         (char-set-union must-be-quoted-chars separator-chars char-set:blank))
     564        (token-string (->string token)))
     565    (if (string-any trigger-quoting-chars token-string)
     566        (quote-string token-string)
     567        token-string)))
    570568
    571569;; There's no need to make a specific header unparser for every header type.
     
    586584                                       attribute
    587585                                       (unparse-token (cdr contents))))))
    588                        ((uri-reference? contents) (unparse-token (uri->string contents)))
     586                       ((uri-reference? contents)
     587                        (unparse-token (uri->string contents) (char-set)))
    589588                       (else (unparse-token contents))))
    590589               (parameter-unparsers '())) ; Maybe we want to make this a param
  • release/4/intarweb/trunk/tests/run.scm

    r15162 r15327  
    514514          (test-unparse-headers `((foo (bar . "qux") (mooh . "mum, ble")))))
    515515    (test "URI"
    516           "Foo: http://foo.com/bar\r\n"
    517           (test-unparse-headers `((foo ,(uri-reference "http://foo.com/bar")))))
     516          "Foo: http://foo.com/bar;xyz?a=b\r\n"
     517          (test-unparse-headers `((foo ,(uri-reference "http://foo.com/bar;xyz?a=b")))))
    518518    (test "Parameters"
    519519          "Foo: bar; Qux=mooh; Mumble=mutter; Blah\r\n"
Note: See TracChangeset for help on using the changeset viewer.