From ada1bcb1af1ccd4fa189ad463b2850e6c1d7d2c9 Mon Sep 17 00:00:00 2001 From: zhangyunhao Date: Wed, 16 Mar 2022 13:32:29 +0800 Subject: [PATCH] Imporve AppendHTMLEscape fast path --- bytesconv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bytesconv.go b/bytesconv.go index a35b6068b6..fac5a39e95 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -19,10 +19,10 @@ import ( // AppendHTMLEscape appends html-escaped s to dst and returns the extended dst. func AppendHTMLEscape(dst []byte, s string) []byte { - if strings.IndexByte(s, '&') < 0 && - strings.IndexByte(s, '<') < 0 && + if strings.IndexByte(s, '<') < 0 && strings.IndexByte(s, '>') < 0 && strings.IndexByte(s, '"') < 0 && + strings.IndexByte(s, '&') < 0 && strings.IndexByte(s, '\'') < 0 { // fast path - nothing to escape