From 4a53e8e5fb26aaa3dbfad553680c70bf0fe4dde9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 29 May 2016 02:09:48 +0000 Subject: [PATCH] txt2pre: remove CGI.pm dependency CGI.pm is no longer in the main Perl distribution, and it's overkill for a single function. --- Documentation/txt2pre | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/txt2pre b/Documentation/txt2pre index aad3673..2dd1597 100755 --- a/Documentation/txt2pre +++ b/Documentation/txt2pre @@ -7,17 +7,25 @@ # and requires indentation to output preformatted text. use strict; use warnings; -use CGI qw/escapeHTML/; use Encode qw/encode/; my $str = eval { local $/; <> }; -$str = escapeHTML($str); +my %xhtml_map = ( + '"' => '"', + '&' => '&', + "'" => ''', + '<' => '<', + '>' => '>', +); +$str =~ s/([<>&'"])/$xhtml_map{$1}/ge; $str = encode('us-ascii', $str, Encode::HTMLCREF); my ($title) = ($str =~ /\A([^\n]+)/); # temporarily swap > for escape so our s!! to add href works. # there's probably a way to do this with only a single s!! ... $str =~ s!>!\e!g; -$str =~ s!\b((ftp|https?)://[\w+\+\&\?\.\%\;/#-]+)!$1!g; +$str =~ s!\b((nntp|ftp|https?)://[\w+\+\&\?\.\%\;/#-]+)!$1!g; + $str =~ s!\e!>!g; # swap escapes back to > print '', -- 2.11.4.GIT