53
53
# elements that change text style
54
54
my %elements_text_style = map {; $_ => 1 }
55
qw( body font table tr th td big small basefont marquee span ),
55
qw( body font table tr th td big small basefont marquee span p div ),
58
58
# elements that insert whitespace
82
82
$ok_attributes{th}{$_} = 1 for qw( bgcolor );
83
83
$ok_attributes{tr}{$_} = 1 for qw( bgcolor );
84
84
$ok_attributes{span}{$_} = 1 for qw( style );
85
$ok_attributes{p}{$_} = 1 for qw( style );
86
$ok_attributes{div}{$_} = 1 for qw( style );
543
545
if (substr($fg,-6) eq substr($bg,-6)) {
546
$self->put_results(font_low_contrast => 1);
546
548
# near-invisibility
547
elsif ($fg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) {
549
} elsif ($fg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) {
548
550
my ($r1, $g1, $b1) = (hex($1), hex($2), hex($3));
550
552
if ($bg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) {
963
972
return "#" . $color;
976
my $color = lc $_[0];
979
# strip leading and ending whitespace
984
my $hex = $html_color{$color};
986
return sprintf("#%06x", $hex);
989
# IF NOT A NAME, IT SHOULD BE A HEX COLOR, HEX SHORTHAND or rgb values
990
if ($color =~ m/^[#a-f0-9]*$|rgb\([\d%, ]*\)/i) {
992
#Convert the RGB values to hex values so we can fall through on the programming
995
if ($color =~ m/rgb\((\d+)%,\s*(\d+)%,\s*(\d+)%\s*\)/i) {
996
$color = "#".dec2hex(int($1/100*255)).dec2hex(int($2/100*255)).dec2hex(int($3/100*255));
1000
if ($color =~ m/rgb\((\d+),\s*(\d+),\s*(\d+)\s*\)/i) {
1001
$color = "#".dec2hex($1).dec2hex($2).dec2hex($3);
1005
if ($color =~ m/^#/) {
1007
$color =~ s/[^a-f0-9]//ig;
1009
# strip to 6 if greater than 6
1010
if (length($color) > 6) {
1011
$color=substr($color,0,6);
1014
# strip to 3 if length < 6)
1015
if (length($color) > 3 && length($color) < 6) {
1016
$color=substr($color,0,3);
1019
# pad right-hand-side to a multiple of three
1020
$color .= "0" x (3 - (length($color) % 3)) if (length($color) % 3);
1022
#DUPLICATE SHORTHAND HEX
1023
if (length($color) == 3) {
1024
$color =~ m/(.)(.)(.)/;
1025
$color = "$1$1$2$2$3$3";
1035
#??RETURN BLACK SINCE WE DO NOT KNOW HOW THE MUA / BROWSER WILL PARSE
1041
#print "DEBUG: before/after name_to_rgb new version: $before/$color\n";
1043
return "#" . $color;
1054
return sprintf("$pre%lx", $dec);
966
1058
use constant URI_STRICT => 0;
968
1060
# resolving relative URIs as defined in RFC 2396 (steps from section 5.2)