[HTTP-Recorder] Another issue with forms and <textareas>

Aidan Kehoe aidan.kehoe at phorest.ie
Fri Jun 11 11:57:18 EDT 2004


Hi,

When Recorder.pm piggybacks the various form details in the HTML that's sent to 
the browser, it puts <input type="hidden" ...> tags immediately after several 
form elements.

This breaks for <textarea>s with Mozilla--possibly other browsers, too--because 
that browser doesn't interpret the text between <textarea> and </textarea> as 
HTML, and rather displays it as text in the form box.

I'm working around this with the attached patch--hopefully this will be useful 
for other users of the package.

Bye, best regards,

-- 

Aidan Kehoe
Technical Officer
nDevor Systems Ltd

Email: aidan.kehoe at phorest.ie
Mobile: +353 86 3874935
Phone: +353 1 8747800 (GMT office hours)
Physical: 69 Middle Abbey Street, Dublin 1, Ireland
Web: http://www.phorest.com/

-------------- next part --------------
--- Recorder.pm.orig	Wed Jun  9 15:57:15 2004
+++ Recorder.pm	Fri Jun 11 15:00:33 2004
@@ -269,7 +268,9 @@
 		push @forms, $token;
 		$formnumber++;
 	    }
-	    $newcontent .= ("<".$tagname);
+
+	    # Store the info for this tag before adding it to $newcontent.
+	    my $taginfo = "<".$tagname;
 
 	    # keep the attributes in their original order
 	    my $attrlist = @$token[3];
@@ -283,13 +284,23 @@
 		    $formfield = ("$prefix-form-".
 				  $formnumber."-".$attrs->{$attr});
 		}
-		$newcontent .= (" ".$attr."=\"".$attrs->{$attr}."\"");
+		$taginfo .= (" ".$attr."=\"".$attrs->{$attr}."\"");
 	    }
-	    $newcontent .= (">\n");
+	    $taginfo .= (">\n");
+
 	    if ($formfield) {
-		$newcontent .= "<input type=\"hidden\" name=\"$formfield\" value=1>\n";
+		# In the event that this tag is a textarea, we can't put the
+		# hidden form value immediately after the opening, because
+		# it'll show up in the text field in the browser. So, we put
+		# it immediately before.
+		$taginfo = '<input type="hidden" name="'.
+		    $formfield.'" value=1>'.$taginfo;
 		$formfield = "";
 	    }
+
+	    $newcontent .= $taginfo;
+	    undef $taginfo;
+
 	    if ($tagname eq 'form') {
 		if (scalar @forms == 1) {
 		    $newcontent .= rewrite_form_content($attrs->{name}, 


More information about the HTTP-Recorder mailing list