问题描述
我有一些我希望链接的文本,我可以合理地使用正则表达式(搜索http / https或www),但我担心XSS并发症。在Perl中执行此操作的安全方法是什么?
I have some text I want to linkify, which I can reasonably do with a regex (search for http/https or www) but I'm worried about XSS complications. What's a safe way to do this in Perl?
推荐答案
XSS并发症的具体含义是什么?您是否只关注JavaScript或使用等也关注你?
Exactly what do you mean by XSS complications? Are you only concerned with JavaScript or do URLs of the form http://example.com/command?type=delete;who=sam etc concern you as well?
至于链接URL,总会有边缘情况,但在各种输入上工作得很好。可以使用方法来预处理链接。
As for linkifying URLs, there will always be edge cases, but Text::Markdown worked pretty well on a variety of inputs when I tried it. You can use the urls method to preprocess the links.
请参阅也 。
这篇关于如何在Perl中链接文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!