简体   繁体   中英

How do I linkify text in 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?

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 .

我无法谈论XSS问题,但是URI :: Find可以让您查找文本中的所有URI,并将其转换为所需的任何内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM