This starts it all:
print '<a href="#" onClick="var xmlHttp = null; xmlHttp = new XMLHttpRequest(); xmlHttp.open( &quot;GET&quot;, &quot;/cgi-bin/bid.js?aid='.( $rBid->{cgi}->param('aid')||-1 ).'&quot; , false ); xmlHttp.send( null ); eval(xmlHttp.responseText); return false;">[Bid]</a> ';

In the above I'm scared that content from the client is being passed without first being quoted. I should escapeHTML this at the vary least, but this is not enough and whatever function I used needs to be secure enough for the job... Ideally I'd only use something provided by the specific make, model, and version of the processor. Understanding this is a remote web browser I'm willing to make certain concessions... Like using escapeHTML or URL escape functions provided by notable CPAN modules.

This is where the problem is:
print $rBid->{session}->header(-type=>'text/javascript'); my $sth = $rBid->{dbh}->prepare( 'INSERT INTO bid VALUES (?, (SELECT bidder_username FROM session WHERE id=?));') or die $rBid->{dbh}->errstr; $sth->execute($rBid->{cgi}->param('aid'), $rBid->{session}->id()||'undef') or print 'alert("Error: '. $rBid->{cgi}->escapeHTML($sth->errstr).'");'."\n"; print 'alert("Bid(s) Placed: '. $rBid->{cgi}->escapeHTML($sth->rows).'");'."\n";
The escapeHTML above is interpreted by the JS and not the HTML processor, as there is no HTML processor. I could switch to using alert('... but then I'd need to escape '.

In reply to Re^2: Perl, JavaScript and quoting/escaping by Anonymous Monk
in thread Perl, JavaScript and quoting/escaping by isync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.