如何在Perl中链接文本? [英] How do I linkify text in Perl?

查看:155
本文介绍了如何在Perl中链接文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些我希望链接的文本,我可以合理地使用正则表达式(搜索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或使用 http://example.com/形式的网址命令?type = delete; who = sam 等也关注你?

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,总会有边缘情况,但 Text :: Markdown 在各种输入上工作得很好。可以使用网址方法来预处理链接。

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中链接文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆