Fixing PR14478
This commit is contained in:
parent
7ce7f9c2f2
commit
7740733c05
|
@ -563,6 +563,9 @@ END
|
|||
"<root> </root>")
|
||||
(test-xexpr->string '(root () 40)
|
||||
"<root>(</root>")
|
||||
(check-exn
|
||||
exn:fail?
|
||||
(λ () (xexpr->string "\f")))
|
||||
; XXX more xexpr->string tests
|
||||
)
|
||||
|
||||
|
|
|
@ -154,15 +154,22 @@
|
|||
(let ([n (entity-text entity)])
|
||||
(fprintf out (if (number? n) "&#~a;" "&~a;") n)))
|
||||
|
||||
(define escape-table #rx"[<>&]")
|
||||
(define escape-table #px"[<>&[:cntrl:]]")
|
||||
(define escape-attribute-table #rx"[<>&\"]")
|
||||
|
||||
(define (replace-escaped s)
|
||||
(case (string-ref s 0)
|
||||
(define c (string-ref s 0))
|
||||
(case c
|
||||
[(#\<) "<"]
|
||||
[(#\>) ">"]
|
||||
[(#\&) "&"]
|
||||
[(#\") """]))
|
||||
[(#\") """]
|
||||
[(#\newline) "\n"]
|
||||
[else
|
||||
(define i (char->integer c))
|
||||
(if (valid-char? i)
|
||||
(format "&#~a;" i)
|
||||
(error 'escape "illegal character, ~v" c))]))
|
||||
|
||||
;; escape : String -> String
|
||||
(define (escape x table)
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
(error 'xexpr->xml
|
||||
"expected a list of xexprs for the body in ~e"
|
||||
x))
|
||||
(make-element 'scheme 'scheme (car x)
|
||||
(make-element 'racket 'racket (car x)
|
||||
atts
|
||||
(map xexpr->xml body)))])
|
||||
(if (and (pair? (cdr x))
|
||||
|
@ -68,9 +68,9 @@
|
|||
(and (pair? (cadr x)) (pair? (caadr x)))))
|
||||
(f (map srep->attribute (cadr x)) (cddr x))
|
||||
(f null (cdr x))))]
|
||||
[(string? x) (make-pcdata 'scheme 'scheme x)]
|
||||
[(string? x) (make-pcdata 'racket 'racket x)]
|
||||
[(or (symbol? x) (exact-nonnegative-integer? x))
|
||||
(make-entity 'scheme 'scheme x)]
|
||||
(make-entity 'racket 'racket x)]
|
||||
[(or (comment? x) (p-i? x) (cdata? x) (pcdata? x)) x]
|
||||
[else ;(error 'xexpr->xml "malformed xexpr ~e" x)
|
||||
x]))
|
||||
|
|
Loading…
Reference in New Issue
Block a user