in reply to Re: Perl, JavaScript and quoting/escaping
in thread Perl, JavaScript and quoting/escaping
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl, JavaScript and quoting/escaping
by Anonymous Monk on May 06, 2011 at 03:37 UTC | |
|
Re^3: Perl, JavaScript and quoting/escaping
by ikegami (Patriarch) on May 06, 2011 at 05:19 UTC | |
by Anonymous Monk on May 06, 2011 at 05:46 UTC | |
by ikegami (Patriarch) on May 06, 2011 at 05:55 UTC | |
by Anonymous Monk on May 06, 2011 at 06:16 UTC |