print '<a href="#" onClick="var xmlHttp = null; xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", "/cgi-bin/bid.js?aid='.( $rBid->{cgi}->param('aid')||-1 ).'" , 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: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 '.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";
In reply to Re^2: Perl, JavaScript and quoting/escaping
by Anonymous Monk
in thread Perl, JavaScript and quoting/escaping
by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |