From 0f0aaf51e01822834a75dff94f1f0f44cc3d31c2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 11:43:59 +0000 Subject: [PATCH] Deal with HTML where ' is used instead of " Cut off name from option --- perl/contrib/formfind | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/perl/contrib/formfind b/perl/contrib/formfind index f3f3d414e..459b2db3c 100755 --- a/perl/contrib/formfind +++ b/perl/contrib/formfind @@ -28,11 +28,11 @@ sub namevalue { my ($tag)=@_; my $name=$tag; if($name =~ /name *=/i) { - if($name =~ /name *= *([^\"]([^ \">]*))/) { + if($name =~ /name *= *([^\"\']([^ \">]*))/) { $name = $1; } - elsif($name =~ /name *= *\"([^\"]*)\"/) { - $name=$1; + elsif($name =~ /name *= *(\"|\')([^\"\']*)(\"|\')/) { + $name=$2; } else { # there is a tag but we didn't find the contents @@ -46,12 +46,12 @@ sub namevalue { } # get value tag my $value= $tag; - if($value =~ /value *=/i) { - if($value =~ /value *= *([^\"]([^ \">]*))/) { + if($value =~ /[^\.a-zA-Z0-9]value *=/i) { + if($value =~ /[^\.a-zA-Z0-9]value *= *([^\"\']([^ \">]*))/) { $value = $1; } - elsif($value =~ /value *= *\"([^\"]*)\"/) { - $value=$1; + elsif($value =~ /[^\.a-zA-Z0-9]value *= *(\"|\')([^\"\']*)(\"|\')/) { + $value=$2; } else { # there is a tag but we didn't find the contents @@ -91,7 +91,7 @@ while($in =~ /[^<]*(<[^>]+>)/g ) { $method="get"; # default method } $action= $tag; - $action=~ s/.*action *= *(\"|)([^ \">]*).*/$2/gi; + $action=~ s/.*action *= *(\'|\"|)([^ \"\'>]*).*/$2/gi; $method=uc($method); @@ -138,14 +138,14 @@ while($in =~ /[^<]*(<[^>]+>)/g ) { ($name, $value)=namevalue($tag); if($mtag =~ /select/i) { - print "Select: $name\n"; + print "Select: NAME=\"$name\"\n"; push @vars, "$name"; $select = 1; } else { $type=$tag; if($type =~ /type *=/i) { - $type =~ s/.*type *= *(\"|)([^ \">]*).*/$2/gi; + $type =~ s/.*type *= *(\'|\"|)([^ \"\'>]*).*/$2/gi; } else { $type="text"; # default type @@ -176,7 +176,7 @@ while($in =~ /[^<]*(<[^>]+>)/g ) { ($tag =~ /^< *textarea/i)) { my ($name, $value)=namevalue($tag); - print "Textarea: $name\n"; + print "Textarea: NAME=\"$name\"\n"; } elsif($select) { if($tag =~ /^< *\/ *select/i) { @@ -185,7 +185,11 @@ while($in =~ /[^<]*(<[^>]+>)/g ) { } elsif($tag =~ /[^\/] *option/i ) { my ($name, $value)=namevalue($tag); - print " One option (name \"$name\") = \"$value\"\n"; + my $s; + if($tag =~ /selected/i) { + $s= " (SELECTED)"; + } + print " Option VALUE=\"$value\"$s\n"; } } }