From 44b3c5890c87bc795256cd75bdd32d4279336aa9 Mon Sep 17 00:00:00 2001 From: mdw Date: Wed, 18 Aug 1999 17:10:07 +0000 Subject: [PATCH] Slight improvements to URL and email address parsing. --- perl/SWDoc.pm | 9 ++++++--- perl/SWInfo.pm | 9 ++++++--- perl/SWMan.pm | 19 +++++++++++-------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/perl/SWDoc.pm b/perl/SWDoc.pm index d87da58..d519b11 100644 --- a/perl/SWDoc.pm +++ b/perl/SWDoc.pm @@ -1,6 +1,6 @@ # -*-perl-*- # -# $Id: SWDoc.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $ +# $Id: SWDoc.pm,v 1.2 1999/08/18 17:10:07 mdw Exp $ # # Display documentation files # @@ -28,6 +28,9 @@ #----- Revision history ----------------------------------------------------- # # $Log: SWDoc.pm,v $ +# Revision 1.2 1999/08/18 17:10:07 mdw +# Slight improvements to URL and email address parsing. +# # Revision 1.1 1999/07/30 18:46:37 mdw # New CGI script for browsing installed software and documentation. # @@ -58,9 +61,9 @@ sub doc { $line =~ s/\&/&/g; $line =~ s/\/>/g; - $line =~ s!(http|ftp)://[^]&)\s]*[^]&).,\s\']!$&!g; + $line =~ s!\b(https?|ftp|file|news):[^]&)\s]*[^]&).,\s\']!$&!g; $line =~ s!info:([^]&)\s]*[^]&).,\s\'\"])!$&!g; - $line =~ s![^\s()&;{}.,\`\"][^\s()&;{}\`\"]*\@[^\s()&;{}\'\"]*[^\s()&;{}.,\'\"]!$&!g; + $line =~ s!(?:\bmailto:)?([^\s()&;:{}.,\`\"][^\s()&;:{}\`\"]*\@[^\s()&;:{}\'\"]*[^\s()&;:{}.,\'\"])!$&!g; $line =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg; print $line; } diff --git a/perl/SWInfo.pm b/perl/SWInfo.pm index 04898df..276ac05 100644 --- a/perl/SWInfo.pm +++ b/perl/SWInfo.pm @@ -1,6 +1,6 @@ # -*-perl-*- # -# $Id: SWInfo.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $ +# $Id: SWInfo.pm,v 1.2 1999/08/18 17:10:07 mdw Exp $ # # Read and output GNU Info files # @@ -28,6 +28,9 @@ #----- Revision history ----------------------------------------------------- # # $Log: SWInfo.pm,v $ +# Revision 1.2 1999/08/18 17:10:07 mdw +# Slight improvements to URL and email address parsing. +# # Revision 1.1 1999/07/30 18:46:37 mdw # New CGI script for browsing installed software and documentation. # @@ -141,8 +144,8 @@ sub info { } $out .= $n; - $out =~ s!(http|ftp)://[^]&)\s]*[^]&).,\s\'\"]!$&!g; - $out =~ s![^\s()&;{}.,\`\"][^\s()&;{}\`\"]*\@[^\s()&;{}\'\"]*[^\s()&;{}.,\'\"]!$&!g; + $out =~ s!\b(https?|ftp|file|news):[^]&)\s]*[^]&).,\s\'\"]!$&!g; + $out =~ s!(?:\bmailto:)?([^\s()&;:{}.,\`\"][^\s()&;:{}\`\"]*\@[^\s()&;:{}\'\"]*[^\s()&;:{}.,\'\"])!$&!g; $out =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg; header("Info: ($file)$node"); diff --git a/perl/SWMan.pm b/perl/SWMan.pm index 23f0104..b27fca8 100644 --- a/perl/SWMan.pm +++ b/perl/SWMan.pm @@ -1,6 +1,6 @@ # -*-perl-*- # -# $Id: SWMan.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $ +# $Id: SWMan.pm,v 1.2 1999/08/18 17:10:07 mdw Exp $ # # Display and other fiddling of manual pages # @@ -28,6 +28,9 @@ #----- Revision history ----------------------------------------------------- # # $Log: SWMan.pm,v $ +# Revision 1.2 1999/08/18 17:10:07 mdw +# Slight improvements to URL and email address parsing. +# # Revision 1.1 1999/07/30 18:46:37 mdw # New CGI script for browsing installed software and documentation. # @@ -288,18 +291,18 @@ sub man { # --- And email and hypertext references too --- $l =~ s! ((?:\<[bi]\>)*) # Leading highlighting - ((?:http|ftp) # A protocol name - :// # The important and obvious bit + ((?:https?|ftp|file|news) # A protocol name + : # The important and obvious bit [^]&)\s]+ # Most characters are allowed [^]&).,\s\'\"]) # Don't end on punctuation ((?:\)*) # Closing tags, optional - !$&!gx; + !$1$&$3!gx; - $l =~ s! ((?:\<[bi]\>)*) - ( [^\s()&;{}<>,.\`\"] [^\s()&;{}<>\`\"]* \@ - [^\s()&;{}<>\'\"]* [^\s()&;{}<>.,\'\"]) + $l =~ s! ((?:\<[bi]\>)*(?:\bmailto:)?) + ( [^\s()&;:{}<>,.\`\"] [^\s()&;:{}<>\`\"]* \@ + [^\s()&;:{}<>\'\"]* [^\s()&;:{}<>.,\'\"]) ((?:\)*) - !$&!gx; + !$1$&$3!gx; # --- Done! --- -- 2.11.0