5 # This script gets a HTML page on stdin and presents form information on
8 # Author: Daniel Stenberg <daniel@haxx.se>
9 # Version: 0.2 Nov 18, 2002
13 # 0.1 - Nov 12 1998 - Created now!
14 # 0.2 - Nov 18 2002 - Enhanced. Removed URL support, use only stdin.
19 if($ARGV[0] eq "-h") {
20 print "Usage: $0 < HTML\n";
27 if($name =~ /name *=/i) {
28 if($name =~ /name *= *([^\"\']([^ \">]*))/i) {
31 elsif($name =~ /name *= *(\"|\')([^\"\']*)(\"|\')/i) {
35 # there is a tag but we didn't find the contents
46 if($value =~ /[^\.a-zA-Z0-9]value *=/i) {
47 if($value =~ /[^\.a-zA-Z0-9]value *= *([^\"\']([^ \">]*))/i) {
50 elsif($value =~ /[^\.a-zA-Z0-9]value *= *(\"|\')([^\"\']*)(\"|\')/i) {
54 # there is a tag but we didn't find the contents
61 return ($name, $value);
73 while($in =~ /[^<]*(<[^>]+>)/g ) {
78 # this is a comment tag, ignore it
82 ($tag =~ /^< *form/i )) {
84 if($method =~ /method *=/i) {
85 $method=~ s/.*method *= *(\"|)([^ \">]*).*/$2/gi;
88 $method="get"; # default method
91 $action=~ s/.*action *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
96 if ($enctype =~ /enctype *=/) {
97 $enctype=~ s/.*enctype *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
99 if($enctype eq "multipart/form-data") {
100 $enctype="multipart form upload [use -F]"
102 $enctype = "\n--- type: $enctype";
108 print "--- FORM report. Uses $method to URL \"$action\"$enctype\n";
112 ($tag =~ /< *\/form/i )) {
114 print "--- end of FORM\n";
117 print "*** Fill in all or any of these: (default assigns may be shown)\n";
123 print "*** Pick one of these:\n";
132 ($tag =~ /^< *(input|select)/i)) {
135 ($name, $value)=namevalue($tag);
137 if($mtag =~ /select/i) {
138 print "Select: NAME=\"$name\"\n";
144 if($type =~ /type *=/i) {
145 $type =~ s/.*type *= *(\'|\"|)([^ \"\'>]*).*/$2/gi;
148 $type="text"; # default type
151 if(lc($type) eq "reset") {
152 # reset types are for UI only, ignore.
155 # let's read the value parameter
157 print "Button: \"$value\" ($type)\n";
158 push @alts, "$value";
161 print "Input: NAME=\"$name\"";
163 print " VALUE=\"$value\"";
167 # store default value:
168 $value{$name}=$value;
173 ($tag =~ /^< *textarea/i)) {
174 my ($name, $value)=namevalue($tag);
176 print "Textarea: NAME=\"$name\"\n";
179 if($tag =~ /^< *\/ *select/i) {
180 print "[end of select]\n";
183 elsif($tag =~ /[^\/] *option/i ) {
184 my ($name, $value)=namevalue($tag);
186 if($tag =~ /selected/i) {
189 print " Option VALUE=\"$value\"$s\n";