The code is as follows. First I import the file:

Gary is testing this program|This is a test of html code.
<table border="2">
<TR>
<TD>
test
</td></tr></table>||http://www.charlotte.com/||||||right||

The script reads it in a splits it by the delimiter, using a subroutine
listed below the html:

        $db_filename = "$db" . "$page\.txt";
        $buffer = read_file($db_filename);
        @fields = split(/\|/, $buffer);
        $headline = "$fields[0]";
        $summary = "$fields[1]";
        $promo = "$fields[2]";
        $url = "$fields[3]";
        $byline =  "$fields[4]";
        $email = "$fields[5]";
        $story = "$fields[6]";
        $file_type = "$fields[7]";
        $cutline = "$fields[8]";
        $placement = "$fields[9]";
        $kill = "$fields[10]";


        print <<"eot";
        <html>
        <head>
        <title>$product $version for $page</title>
        </head>
        <body bgcolor="white">
       
        <form
enctype="multipart/form-data" method="POST" 
action="/cgi-bin/newsmaker/upload_newsmaker.cgi">
        <INPUT TYPE="hidden" NAME="page" VALUE="$page" SIZE=50>
        <table border="0" width=420 cellspacing="2" cellpadding="2">
        <tr>
        <td valign="top" colspan=2>
        <center>$font_big<B>$product $version
        <BR>for:</font></b> <font
face="arial,helvetica" size="+1" color="red"><B>$page</b></font></b></font><BR>
        $font_small <I><font color="red">*</font> denotes mandatory
field</font>
        </center></td></tr>
        <tr>
        <td valign="top">
        $font_big<font
color="red"><B>*</b></font><B>HEADLINE:</B></font></td>
        <td valign="top">
        <input type="text" size=40 name="headline" value="$headline">
        </td></tr>
        <tr><td valign="top">
        $font_big<font
color="red"><B>*</b></font><B>SUMMARY:</B></font></td>
        <td valign="top"><textarea
name="summary" rows="20" cols="60" value="$summary">$summary</textarea>
        </td>
        </tr>
... etc.
        <tr>
        <td valign="top">
        <input type="submit" name="ViewOption" value="Submit"><BR>
        
        </td>
        </tr>
        </table></form>
        </body>
        </html>
eot
}

sub read_file 
{
                        my($filename) = shift;
                        my($buffer);
                        local($/) = undef;
                        open(FILE, $filename)
                        $buffer = <FILE>;
                        close(FILE);
                        return($buffer);
}



On Sat, 6 Jan 2001, Carl Jolley wrote:

> On Sat, 6 Jan 2001, Gary Nielson wrote:
> 
> > Hi,
> > 
> > I noticed a problem with a cgi script I am writing that generates a
> > form. The user fills out the form, the contents of which I use in other
> > programs. If the user wants to edit her form, she simply later calls up
> > the script using the query string environment variable tacked on to the
> > end of the script, as in script.cgi?formname. Works great.
> > 
> > However, I am having a problem with double quotation marks being used
> > inside html brackets. The form is such that some users want to be able to
> > put in their custom html code inside certain fields. If the html tags do
> > not contain quotation marks (as in <table border=0>, the field contents
> > are imported back into the form just fine. But if she adds double
> > quotation marks (as in <table border="0">, the contents imported into the
> > field are all screwwed up.
> > 
> > For example, here is what it looks like when you import data in my cgi
> > script into a field in an html form.
> > 
> > This is a test of html code.
> > <table border=2>
> > <TR>
> > <TD>
> > test
> > </td></tr></table>
> > 
> > and look how part of the code repeats itself and adds a "> in there when
> > you add quotes around the number 2:
> > 
> > <TR>
> > <TD>
> > test
> > </td></tr></table>">This is a test of html code.
> > <table border="2">
> > <TR>
> > <TD>
> > test
> > </td></tr></table>
> > 
> > How can I fix this? I tried escaping the quotation marks in my variable
> > for that field, substituting \" for ", but that did not work. I could tell
> > my users not to use quotation marks within brackets, but I would hate to
> > restrict them needlessly. Any advice, suggestions appreciated.
> >
> 
> Without seeing the code that is handing/mishandling the quote characters
> it it difficult to suggest how it might be modified to work correctly.
> 
> **** [EMAIL PROTECTED] <Carl Jolley>
> **** All opinions are my own and not necessarily those of my employer ****
> 
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 

-- 
Gary Nielson
[EMAIL PROTECTED]




_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to