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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.