cherry-markdown icon indicating copy to clipboard operation
cherry-markdown copied to clipboard

[Feature Request]建议支持对 style 属性的过滤

Open MinMinEr opened this issue 1 year ago • 6 comments

Prerequisites

  • [X] There isn't an existing issue that requests the same feature, to avoid duplicates.

Clear and concise description of the problem

使用场景是聊天室,内容来自于用户输入.用户可能会输入如<h1 style="color: red; font-size: 40px|'>Test

这样的内容.我们希望将style过滤掉 image

Suggested solution

建议支持对 style 属性的过滤

Further Information

No response

Contributing

None

MinMinEr avatar Sep 27 '24 08:09 MinMinEr

🤔 这个不应该是在输入框的时候进行限制嘛? 而不是在渲染的时候,如果是聊天内容,后端也要做xss防范过滤吧?

RSS1102 avatar Sep 27 '24 08:09 RSS1102

🤔@sunsonliu 你怎么看呢?

RSS1102 avatar Sep 27 '24 08:09 RSS1102

🤔@sunsonliu 你怎么看呢?

额。。支持呗,也不是很难。我差不多实现了。等下测试下没问题就提交

sunsonliu avatar Sep 27 '24 08:09 sunsonliu

new Cherry({
    engine: {
        syntax: {
            htmlBlock: {
                /**
                * 是否过滤html标签中的style属性
                *    true:过滤style属性
                *    false:不过滤style属性
                */
                filterStyle: true,
            }
        }
    }
})

这样就可以过滤html标签里的style属性了哈

sunsonliu avatar Sep 27 '24 08:09 sunsonliu

new Cherry({
    engine: {
        syntax: {
            htmlBlock: {
                /**
                * 是否过滤html标签中的style属性
                *    true:过滤style属性
                *    false:不过滤style属性
                */
                filterStyle: true,
            }
        }
    }
})

这样就可以过滤html标签里的style属性了哈

直接实现过滤器岂不是更好?

xuliuzhu1834 avatar Sep 29 '24 02:09 xuliuzhu1834

直接实现过滤器岂不是更好?

额,只想着简单实现,就没怎么考虑扩展性,目前这方面的反馈还是比较少的,就打算简单实现好了。

sunsonliu avatar Oct 08 '24 09:10 sunsonliu