View previous topic :: View next topic |
Author |
Message |
jonny -
Joined: 09 Sep 2004 Posts: 2
|
Posted: Thu Sep 09, 2004 1:34 pm Post subject: Space in wrong place |
|
|
I have perlscript and found out that space in wrong place could be fatal.
Here is a pice of code where I print out a form to the browser:
print <<END_OF_TEXT;
...some code
# here there is a space beetwen '= " ' in 'name= "reset" ' statement:
<INPUT TYPE ="reset" name= "reset" value ="Reset the Form">
# and here there is no space beetwen '= "' in 'name="submit"'
<INPUT type ="submit" name="submit" value ="Submit Comment">
..some more code
END_OF_TEXT
When perl has processed the script the browser looks like this:
I get a space after 'name=" ' in name=" reset" making the name value to be wrong. Or 'value' or whatever there is a space in the wrong place in the perl-script.
<INPUT TYPE ="reset" name=" reset" value ="Reset the Form">
this line is processed OK!
<INPUT type ="submit" name="submit" value ="Submit Comment">
Why do I get these space in wrong palce?
Is this a bug or whatever??
Regards
/Jonny |
|
Back to top |
|
|
jonny -
Joined: 09 Sep 2004 Posts: 2
|
Posted: Fri Sep 10, 2004 1:17 pm Post subject: Code example |
|
|
I have here a complete example of code and the result.
As far as I found out the webbserver is placing a space in wrong place.
Bug or whatever??
/Jonny
#!/usr/local/bin/perl
print PrintHeader();
# here the code is processed and saved to a file, not transferred by the webbserver
open (UTT, ">test.txt");
print UTT &uttForm();
close (UTT);
# here the code is processed and send to the browser by the webbserver.
print &uttForm();
exit;
############################################################################
sub PrintHeader {
return "Content-type: text/html\n\n";
}
sub uttForm
{
local ($title) = @_;
return <<END_OF_TEXT;
<HTML>
<HEAD>
<TITLE>$title</TITLE>
</HEAD>
<BODY>
<H4><FORM METHOD="POST" ACTION="http:/cgi-bin/test/store.pl?edit">
<P>Title: <INPUT TYPE ="text" NAME ="name" VALUE ="" size ="35"><BR>
Notes:<BR>
<TEXTAREA NAME =\"comments\" ROWS = 15 COLS = 45></TEXTAREA></P>
<INPUT TYPE ="reset" name= \"reset\" value ="Reset the Form">
<INPUT type = "submit" name="submit" value ="Submit Comment">
</P>
</FORM></H4>
</BODY>
</HTML>
END_OF_TEXT
}
###### end of code #############################
############################################
This is the result from the test.txt file:
All is processed OK.
The space is between the equal sign = and the quotation mark"!
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H4><FORM METHOD="POST" ACTION="http:/cgi-bin/test/store.pl?edit">
<P>Title: <INPUT TYPE ="text" NAME ="name" VALUE ="" size ="35"><BR>
Notes:<BR>
<TEXTAREA NAME ="comments" ROWS = 15 COLS = 45></TEXTAREA></P>
<INPUT TYPE ="reset" name= "reset" value ="Reset the Form">
=====================|=====
<INPUT type = "submit" name="submit" value ="Submit Comment">
==========|======
</P>
</FORM></H4>
</BODY>
</HTML>
This is the source code from the webbrowser(Mozilla 1.7)
See this under line ===== where wrong spaces are inserted!
The space is placed between and the quotation mark" and the first letter
inside in the string!
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H4><FORM METHOD="POST" ACTION="http:/cgi-bin/test/store.pl?edit">
<P>Title: <INPUT TYPE ="text" NAME ="name" VALUE ="" size ="35"><BR>
Notes:<BR>
<TEXTAREA NAME ="comments" ROWS = 15 COLS = 45></TEXTAREA></P>
<INPUT TYPE ="reset" name=" reset" value ="Reset the Form">
======================|====
<INPUT type =" submit" name="submit" value ="Submit Comment">
===========|======
</P>
</FORM></H4>
</BODY>
</HTML> |
|
Back to top |
|
|
|