summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-12-12 11:43:59 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-12-12 11:43:59 +0000
commit0f0aaf51e01822834a75dff94f1f0f44cc3d31c2 (patch)
tree9bb38d099d5600af3742ac0e58c0105e280f1991 /perl
parentb5f493c55a6bc955e30392037341978d3605d40c (diff)
downloadcurl-0f0aaf51e01822834a75dff94f1f0f44cc3d31c2.tar.gz
Deal with HTML where ' is used instead of "
Cut off name from option
Diffstat (limited to 'perl')
-rwxr-xr-xperl/contrib/formfind28
1 files 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";
}
}
}