diff options
Diffstat (limited to 'test/data/jsonp.php')
-rw-r--r-- | test/data/jsonp.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/data/jsonp.php b/test/data/jsonp.php index 6c13d72e9..51eee1c6f 100644 --- a/test/data/jsonp.php +++ b/test/data/jsonp.php @@ -1,14 +1,15 @@ <?php error_reporting(0); +function cleanCallback( $callback ) { + return preg_replace( '/[^a-z0-9_]/i', '', $callback ); +} $callback = $_REQUEST['callback']; if ( ! $callback ) { $callback = explode("?",end(explode("/",$_SERVER['REQUEST_URI']))); $callback = $callback[0]; } -$json = $_REQUEST['json']; -if($json) { - echo $callback . '([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])'; -} else { - echo $callback . '({ "data": {"lang": "en", "length": 25} })'; -} +$json = $_REQUEST['json'] ? + '[ { "name": "John", "age": 21 }, { "name": "Peter", "age": 25 } ]' : + '{ "data": { "lang": "en", "length": 25 } }'; +echo cleanCallback( $callback ) . '(' . $json . ')'; ?> |