summaryrefslogtreecommitdiff
path: root/includes/api/ApiFormatJson.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/api/ApiFormatJson.php
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/api/ApiFormatJson.php')
-rw-r--r--includes/api/ApiFormatJson.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php
index abb63480..342a580f 100644
--- a/includes/api/ApiFormatJson.php
+++ b/includes/api/ApiFormatJson.php
@@ -56,30 +56,32 @@ class ApiFormatJson extends ApiFormatBase {
}
public function execute() {
- $prefix = $suffix = '';
-
$params = $this->extractRequestParams();
+ $json = FormatJson::encode(
+ $this->getResultData(),
+ $this->getIsHtml(),
+ $params['utf8'] ? FormatJson::ALL_OK : FormatJson::XMLMETA_OK
+ );
$callback = $params['callback'];
- if ( !is_null( $callback ) ) {
- $prefix = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $callback ) . '(';
- $suffix = ')';
+ if ( $callback !== null ) {
+ $callback = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $callback );
+ $this->printText( "$callback($json)" );
+ } else {
+ $this->printText( $json );
}
- $this->printText(
- $prefix .
- FormatJson::encode( $this->getResultData(), $this->getIsHtml() ) .
- $suffix
- );
}
public function getAllowedParams() {
return array(
- 'callback' => null,
+ 'callback' => null,
+ 'utf8' => false,
);
}
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.',
+ 'utf8' => 'If specified, encodes most (but not all) non-ASCII characters as UTF-8 instead of replacing them with hexadecimal escape sequences.',
);
}