消毒单词后撇号变化

Apostrophe changes after sanitizing word

提问人:Antonio Toche 提问时间:1/20/2023 更新时间:1/20/2023 访问量:47

问:

package main

import (
"log"
"github.com/microcosm-cc/bluemonday"
)

func main() {
c := "hello doesn't work 😖"

    p := bluemonday.UGCPolicy()
    
    log.Println(p.Sanitize(c))

}

预期的输出应该是我收到的hello doesn't work 😖hello doesn't work 😖

我尝试将允许列表与正则表达式一起使用,但它不起作用

HTML Go 文本 UTF-8 清理

评论


答:

0赞 dave 1/20/2023 #1

这并不是 HTML 上下文中的真正变化,如下所示:

<div>hello doesn't work 😖</div>
<div>hello doesn&#39;t work 😖</div>