# | Line 77 | Line 77 | exit 0; | |
---|---|---|
77 | ||
78 | # Print a file, whilst escaping HTML: - | |
79 | sub print_file ($) { | |
80 | + | my ($urls) = '(' . join ('|', qw{ |
81 | + | http |
82 | + | telnet |
83 | + | gopher |
84 | + | file |
85 | + | wais |
86 | + | ftp |
87 | + | } ) |
88 | + | . ')'; |
89 | + | |
90 | + | my ($ltrs) = '\w'; |
91 | + | my ($gunk) = '/#~:.?+=&%@!\-'; |
92 | + | my ($punc) = '.:?\-'; |
93 | + | my ($any) = "${ltrs}${gunk}${punc}"; |
94 | my ($filename) = @_; | |
95 | open(FILE, $filename) or die "Cannot open $filename: $!\n"; | |
96 | print "<pre>\n"; | |
# | Line 87 | Line 101 | sub print_file ($) { | |
101 | s/</</g; | |
102 | s/>/>/g; | |
103 | s/"/"/g; | |
104 | + | s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox; |
105 | print; | |
106 | } | |
107 | print "</pre>"; |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |