Avoid regexp-replace* unless the string really contains escapable characters.
This commit is contained in:
parent
40116eb16d
commit
5cb2f3eb58
|
@ -168,7 +168,15 @@
|
||||||
(define (escape x table)
|
(define (escape x table)
|
||||||
(regexp-replace* table x replace-escaped))
|
(regexp-replace* table x replace-escaped))
|
||||||
|
|
||||||
|
(define (display/escape x table out)
|
||||||
|
(cond [(regexp-match table x)
|
||||||
|
(display (escape x table) out)]
|
||||||
|
[else
|
||||||
|
(display x out)]))
|
||||||
|
|
||||||
|
|
||||||
(provide escape
|
(provide escape
|
||||||
|
display/escape
|
||||||
escape-table
|
escape-table
|
||||||
escape-attribute-table
|
escape-attribute-table
|
||||||
lowercase-symbol
|
lowercase-symbol
|
||||||
|
|
|
@ -141,7 +141,7 @@
|
||||||
(display (car att) out)
|
(display (car att) out)
|
||||||
(display "=" out)
|
(display "=" out)
|
||||||
(display "\"" out)
|
(display "\"" out)
|
||||||
(display (escape (cadr att) escape-attribute-table) out)
|
(display/escape (cadr att) escape-attribute-table out)
|
||||||
(display "\"" out))
|
(display "\"" out))
|
||||||
; Write end of opening tag
|
; Write end of opening tag
|
||||||
(if (and (null? content)
|
(if (and (null? content)
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
(display ">" out)))]
|
(display ">" out)))]
|
||||||
; PCData
|
; PCData
|
||||||
[(string? x)
|
[(string? x)
|
||||||
(display (escape x escape-table) out)]
|
(display/escape x escape-table out)]
|
||||||
; Entities
|
; Entities
|
||||||
[(symbol? x)
|
[(symbol? x)
|
||||||
(display "&" out)
|
(display "&" out)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user