1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-29 11:24:10 +01:00

Fix - PHP: Validate the JSONP callback as a valid Javascript function

This commit is contained in:
Allan Jardine 2015-07-15 17:11:15 +01:00
parent 994121d024
commit 3d3f72aec6
2 changed files with 11 additions and 4 deletions

View File

@ -1 +1 @@
a93fb4bfd244230f71f8c9dea10102f0b1cb4ff0 76239c3054300b0e3658a9ab2fce901c255d1537

View File

@ -63,7 +63,14 @@ $sql_details = array(
*/ */
require( 'ssp.class.php' ); require( 'ssp.class.php' );
echo $_GET['callback'].'('.json_encode( // Validate the JSONP to make use it is an okay Javascript function to execute
$jsonp = preg_match('/^[$A-Z_][0-9A-Z_$]*$/i', $_GET['callback']) ?
$_GET['callback'] :
false;
if ( $jsonp ) {
echo $jsonp.'('.json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ) SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
).');'; ).');';
}