> Fails on this:
>
> <body onLoad="foo='bar'" background='image>.jpg'>
>
> --
> Jason King
That was an interesting one, very well spotted, thanks. It only took a couple of
minutes to figure out though. It was just a matter of adding ">$" to the unless loops.
Anyway, here is the fixed version.
-----------------------------------------------------------
#!/usr/bin/perl
#bodytag_v2.3.pl
#regex that matches the body tag
use warnings;
use strict;
my $counter = 0;
my $bookmark = 0;
my $bodytag = "";
my $ignorecode = 0;
$/ = ">";
open FILE, "bodytag.htm" or die "Could not open the file bodytag.htm: $!";
while ( <FILE> ) {
if ( /<!--.*(?!-->)/s ) {
$ignorecode = 1;
}
if ( /-->/ ) {
$ignorecode = 0;
}
if ( /<\s*[^\/]*SCRIPT.*>/igs ) {
$ignorecode = 1;
}
if ( /<\s*\/.*SCRIPT.*>/igs ) {
$ignorecode = 0;
}
$counter++;
next if ( $ignorecode );
if ( /<\s*(BODY)(.*)>/igs ) {
$bodytag .= $_;
$bookmark = $counter;
}
if ( $counter == $bookmark+1 ) {
if ( $bodytag =~ /<\s*(BODY)(.*)(=\s*["][^"]*)>$/igs ) {
unless ( $bodytag =~ /=.*'.*=.*"+.*'>$/ ) {
if ( /.*["].*>/igs ) {
$bodytag .= $_;
$bookmark = $counter;
}
elsif ( /[^"]*['>]+[^"]*/ ) {
$bodytag .= $_;
$bookmark = $counter;
next;
}
}
}
elsif ( $bodytag =~ /<\s*(BODY)(.*)(=\s*['][^']*)>$/igs ) {
unless ( $bodytag =~ /=.*".*=.*'+.*">$/ ) {
if ( /.*['].*>/igs ) {
$bodytag .= $_;
$bookmark = $counter;
}
elsif ( /[^']*[">]+[^']*/ ) {
$bodytag .= $_;
$bookmark = $counter;
next;
}
}
}
}
#print "\nDEBUG: counter = $counter\tbookmark = $bookmark";
}
close FILE;
$bodytag =~ s/\n/ /g;
$bodytag =~ s/\s{2,}/ /g;
$bodytag =~ s/\s(>)$/$1/;
$bodytag =~ s/^ *(<)\s*(BODY.*)\s*$/$1$2/ig;
print "\n$bodytag\n";
-----------------------------------------------------------
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
One click access to the Top Search Engines
http://www.exactsearchbar.com/mailcom
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs