}
/**
- * @addtogroup API
+ * @ingroup API
*/
class ApiFormatJson extends ApiFormatBase {
$params = $this->extractRequestParams();
$callback = $params['callback'];
if(!is_null($callback)) {
- $prefix = ereg_replace("[^_A-Za-z0-9]", "", $callback ) . "(";
+ $prefix = preg_replace("/[^][.\\'\\\"_A-Za-z0-9]/", "", $callback ) . "(";
$suffix = ")";
}
- if (!function_exists('json_encode') || $this->getIsHtml()) {
+ // Some versions of PHP have a broken json_encode, see PHP bug
+ // 46944. Test encoding an affected character (U+20000) to
+ // avoid this.
+ if (!function_exists('json_encode') || $this->getIsHtml() || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') {
$json = new Services_JSON();
$this->printText($prefix . $json->encode($this->getResultData(), $this->getIsHtml()) . $suffix);
} else {
}
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'callback' => null
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
- 'callback' => 'If specified, wraps the output into a given function call',
+ 'callback' => 'If specified, wraps the output into a given function call. For safety, all user-specific data will be restricted.',
);
}
- protected function getDescription() {
+ public function getDescription() {
if ($this->mIsRaw)
return 'Output data with the debuging elements in JSON format' . parent :: getDescription();
else
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiFormatJson.php 23531 2007-06-29 01:19:14Z simetrical $';
+ return __CLASS__ . ': $Id: ApiFormatJson.php 45682 2009-01-12 19:06:33Z raymond $';
}
}
-