Single comments causing runtime problems

Posted on 2000-04-19
Medium Priority
Last Modified: 2010-03-05
I have a form that calls a perl script.  When the user enters a single comment character it causes my perl script to blow up when I try printing that field.  So my code looks like:

$comment= $query->param('comment');

and later on

print $comment;

I know it must be sonething simple - any ideas?
Question by:gregreeve
  • 3
  • 2
  • 2
LVL 16

Accepted Solution

maneshr earned 150 total points
ID: 2730591
did you print the Content-type: MIME header before you printed $comment??

here is a code that i used and it works fine with ' quotes.

i used POST and GET and it worked fine!!
Also instead of input type=text i used <textarea>. Again all was ok.

<FORM method=POST action="/cgi-bin/test.pl">
<input type=text name=comment>
<input type=submit>

use CGI;
$query=new CGI;

$comment= $query->param('comment');

print "Content-type: text/html\n\n";
print $comment,"\n";
LVL 85

Expert Comment

ID: 2731723
Is it the perl script that blows up, or the browser?
In what way does it blow up?

Author Comment

ID: 2733623
its the perl script that complains about there being a non terminated single quote.
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.


Author Comment

ID: 2733627
sorry - I need to be clearer.

I am accepting input, printing it to the mailer (sending mail) and then I print a 'Location:http//.....' at the end to send the user to a web page.

I will try the Content-type though...


Author Comment

ID: 2733666
Thanks - my mistake was to put the $comment in quotes before as a part of the print string.  Now it works fine.

Many Thanks - enjoy your points!
LVL 16

Expert Comment

ID: 2740417
Glad to have been of help to you :-)

LVL 85

Expert Comment

ID: 2740735
How did putting $comment in quotes cause a problem?

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question