Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

! (exclamation mark) randomly appearing

Status
Not open for further replies.

sambo80

Technical User
Oct 4, 2005
11
GB
On our website:

When a customer downloads our products, he/she fills in the following form:


Once he fills this, in the back-end a perl script is called 'downloadmca.pl'.

This is processed, and then the user is redirected to a thank you page.

An email is then sent (from the perl script) to the user confirming this. This email is not displaying the correct output. Even though I have uploaded the script on many occasions.

There is an annoying ! (exclamation mark) that keeps appearing in the output text. But this changes position randomly with each email request. This also appears in the email subject line once you click on the email links.

We've downgraded the MIME::Lite problem, and that didn't help.

Has anyone got any idea, why this charater may be appearing? The perl script has no ! characters in it...we've done a search on it to check as well.

Any help would be appreciated.

Cheers

Sambo
 

need more data

Can you post the perl script that generates the emails?

Ta,

fish

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
heres the perl script: (its a bit long)

**************************************
Code:
#!/usr/bin/perl

use CGI::Carp qw{fatalsToBrowser};

##############################################################################
# Software download                                      Version 1.0         #
##############################################################################
# ------------------------------------------------------------
# Form-mail.pl, by Reuven M. Lerner (reuven@the-tech.mit.edu).
#
# Last updated: March 14, 1994
#
# Form-mail provides a mechanism by which users of a World-
# Wide Web browser may submit comments to the webmasters
# (or anyone else) at a site.  It should be compatible with
# any CGI-compatible HTTP server.
# 
# Please read the README file that came with this distribution
# for further details.
# ------------------------------------------------------------

# ------------------------------------------------------------
# This package is Copyright 1994 by The Tech. 

# Form-mail is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.

# Form-mail is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Form-mail; see the file COPYING.  If not, write to the Free
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# ------------------------------------------------------------

# Define fairly-constants

# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail -t';

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);

    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    # $value =~ s/~!/ ~!/g; 

    # Uncomment for debugging purposes
    # print "Setting $name to $value<P>";

    $FORM{$name} = $value;
}

# This should be set to the username or alias that runs your
# [URL unfurl="true"]WWW server.[/URL]
$recipient = $FORM{'email'};


# Now send mail to Pertmaster
open (MAIL, "|$mailprog") || die "Can't open $mailprog!\n";
print MAIL "From: $FORM{'email'} \n";
print MAIL "To: downloadmca\@pertmaster.com \n";
print MAIL "Subject: $FORM{'company'}-$FORM{'name'}, [URL unfurl="true"]WWW download[/URL] \n\n";
print MAIL "name = $FORM{'name'}\n";
print MAIL "company = $FORM{'company'}\n";

print MAIL "email = $FORM{'email'}\n";
print MAIL "country = $FORM{'country'}\n";
print MAIL "tel = $FORM{'tel'}\n";

print MAIL "\n------------------------------------------------------------\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);

# Now send mail to user
use MIME::Lite;
use Net::SMTP;

my $from_address = 'sales@pertmaster.com';
my $to_address = $recipient;
my $subject = "Welcome to MonteCarlo Analyzer!";
my $mime_type = "text/html";

# This $message_body has HTML formatting in it:
my $message_body = "<htmL>";
$message_body = $message_body."<link href='[URL unfurl="true"]http://www.pertmaster.com/inc/layoutStyles.css'[/URL] rel='stylesheet' type='text/css'>";
$message_body = $message_body."<link href='[URL unfurl="true"]http://www.pertmaster.com/inc/contentStyles.css'[/URL] rel='stylesheet' type='text/css'>";
$message_body = $message_body."<body><table width='635' height='100%' border='0' cellpadding='0' cellspacing='0'>";
$message_body = $message_body."<tr><td valign='top' class='copyColumnCopy' width='490'> ";
$message_body = $message_body."<table width='96%' border='0' cellspacing='0' cellpadding='4'>";
$message_body = $message_body."<tr><td valign='top'>";
$message_body = $message_body."<div class='homeBox' style='height:155px;'><table width='487' ><tr><td width='47'> <br>";
$message_body = $message_body."<div align='left'><a href='[URL unfurl="true"]http://www.pertmaster.com'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/Small_Logo.jpg'[/URL] border='0'alt='Pertmaster Logo' ></a></div></td>";
$message_body = $message_body."<td width='496'> <div align='center'><b><font face='Arial Narrow' size='5pt'>MonteCarlo Analyzer Evaluation</font></b><br> ";
$message_body = $message_body."<font face='Arial Narrow' size='4pt' color='#9B052A'><b>Download Confirmation </b></font></div></td></tr></table>"; 
$message_body = $message_body."<table width='485' border='0' class='mainCopy'  ><tr><td><br>Dear <b>$FORM{'name'}</b>,";
$message_body = $message_body."<p>Thanks for your interest in MonteCarlo Analyzer software and we hope that you will have a successful evaluation.</p>";
$message_body = $message_body."<p>The licence number required for this evaluation is <b>4400-1015-8492-0021-9348</b>.</p>";
$message_body = $message_body."<p>To get started quickly try running through the Tutorial under the Help menu. Our Tutorial provides you with a step by step guide to running MCA as a powerful risk add-on to Primavera.</p>";
$message_body = $message_body."<p>Kind regards.<br><br>Pertmaster Software Team</p>";

#UK address
$message_body = $message_body."<table width='100%' border='0'><tr><td><p><b><font size='1'>In the UK:</font></b><font size='1'><br>";
$message_body = $message_body."Pertmaster Ltd<br>The Surrey Technology Centre<br>40 Occam Road<br>Guildford, Surrey<br>GU2 7YG<br>United Kingdom<br><br>";
$message_body = $message_body."tel: +44 (0)1483 685 190<br>fax: +44 (0)1483 573 704<br>email: <a href='mailto:info@pertmaster.com?subject=MCA Query'>info\@pertmaster.com</a></font></p>";

#US address
$message_body = $message_body."</td><td><b><font size='1'>In the US:</font></b><font size='1'><br>";
$message_body = $message_body."Pertmaster Llc<br>2100 West Loop South<br>Suite 900<br>Houston<br>TX 77027<br>USA<br><br>";
$message_body = $message_body."tel: +1 713 595 7656<br>fax: +1 713 595 7657<br>";
$message_body = $message_body."email: <a href='mailto:info\@pertmaster.com?subject=Monte Carlo Analyzer Query'>info@pertmaster.com</a></font></td></tr></table>";

$message_body = $message_body."<p>***********************************************************<br>";
$message_body = $message_body."This e-mail and any attachments are confidential and may also be ";       
$message_body = $message_body."privileged.<br> If you are not the named recipient, please notify the ";      
$message_body = $message_body."sender immediately<br> and do not disclose the contents to another person,"; 
$message_body = $message_body."use it for any purpose,<br> or store or copy the information in any medium.";
$message_body = $message_body."Any views or opinions<br> presented are solely those of the author and do  ";
$message_body = $message_body."not necessarily represent<br> those of Pertmaster. Pertmaster is unable to ";
$message_body = $message_body."guarantee the security<br> (especially that of attached files) of any email content outside of our own<br> computer systems.";                        
$message_body = $message_body."<br>***********************************************************</p></td></tr></table></div></td></tr></table></td>";
$message_body = $message_body."<td valign='top' width='145'><br><div><img src='[URL unfurl="true"]http://www.pertmaster.com/mcanalyzer/images/MCApricing4_4.gif'[/URL] border='0'></a></div><br>";      
#$message_body = $message_body."<div><a href='[URL unfurl="true"]http://www.mcanalyzer.com/'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/MCAlink.gif'[/URL] border='0'></a></div>";  
#$message_body = $message_body."<div><a href='[URL unfurl="true"]http://www.pertmaster.com/events/training'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/PertmasterTraining.gif'[/URL] border='0' alt='Pertmaster Training Courses'></a></div>";
#$message_body = $message_body."<br><div><a href='[URL unfurl="true"]http://www.primavera.com/solutions/knowledge_center.html'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/PrimaveraWebinar.gif'[/URL] border='0' alt='Primavera Webinar'></a></div>";
$message_body = $message_body."</td></tr></table></body></html>";


# Create the initial text of the message
my $mime_msg = MIME::Lite->new(
   From => $from_address,
   To   => $to_address,
   Subject => $subject,
   Type => $mime_type,
   Data => $message_body
   )
  or die "Error creating MIME body: $!\n";

$mime_msg->send(  ); 


# Show them where to download
print "Location:[URL unfurl="true"]http://www.pertmaster.com/mcanalyzer/downloads/software_thanks.htm\n\n";[/URL]
 
A few suggestions here:
1) it is often considered good practice to run any CGI scripts like this with taint checking (using the -T switch).
2) Using "fatalsToBrowser" is fine for testing but possibly not quite so useful when your customers might see the output. You might like to consider some other kind of error handling when this script is used "live".
3) Debugging this issue is possibly best handled by looking at snapshots of the data that is being fed to this script. Since the script is reading the data into "$buffer", you might like to write this buffer to a file so that firstly you can see if the data is corrupted before the script process it and secondly to enable you to single step the script if necessary with some real sample data.
4) my $message_body = "<htmL>"; has a capital "L" at the end. A minor point but you might like to fix it anyway.
5) $message_body = $message_body."blahblahblah"; could be better (and more succinctly) written as $message_body .= "blahblahblah";

Hopefully that gives you some ideas that will help.



Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top