How do I linkify text in Perl?

。_饼干妹妹 提交于 2019-12-24 19:52:32

问题


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?


回答1:


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?

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.

See also Regexp::Common.




回答2:


I can't speak to the XSS issue, but URI::Find will let you find all URIs in text and transform them into whatever you like.



来源:https://stackoverflow.com/questions/1608094/how-do-i-linkify-text-in-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!