From b2d1c1a4b19404a2ad412755e4e1f55af7d3dcaf Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Sat, 15 Aug 2009 20:24:30 +0000 Subject: [PATCH] * added content-type plain/text output param for json format * added content-type "application/json" or 'text/javascript' per callback param --- includes/api/ApiFormatJson.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php index 1d7e3dccd3..888be28336 100644 --- a/includes/api/ApiFormatJson.php +++ b/includes/api/ApiFormatJson.php @@ -41,7 +41,16 @@ class ApiFormatJson extends ApiFormatBase { } public function getMimeType() { - return 'text/javascript'; + $params = $this->extractRequestParams(); + //callback: + if( $params['callback']){ + return 'text/javascript'; + } + //check for text content request + if( isset( $params['ctypetext']) && $params['ctypetext']) { + return 'text/plain'; + } + return 'application/json'; } public function getNeedsRawData() { @@ -84,13 +93,15 @@ class ApiFormatJson extends ApiFormatBase { public function getAllowedParams() { return array ( - 'callback' => null + 'callback' => null, + 'ctypetext' => null ); } public function getParamDescription() { return array ( 'callback' => 'If specified, wraps the output into a given function call. For safety, all user-specific data will be restricted.', + 'ctypetext'=> 'Used to set the content type of the json result to plain-text (useful for evaling iframe uploads)', ); } -- 2.20.1