dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Remove X-Content-Dimensions header"
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiFormatJson.php
diff --git
a/includes/api/ApiFormatJson.php
b/includes/api/ApiFormatJson.php
index
1566a0f
..
e5dafae
100644
(file)
--- a/
includes/api/ApiFormatJson.php
+++ b/
includes/api/ApiFormatJson.php
@@
-42,7
+42,7
@@
class ApiFormatJson extends ApiFormatBase {
# outside the control of the end user.
# (and do it here because ApiMain::reportUnusedParams() gets called
# before our ::execute())
# outside the control of the end user.
# (and do it here because ApiMain::reportUnusedParams() gets called
# before our ::execute())
- $this->getMain()->
getCheck
( '_' );
+ $this->getMain()->
markParamsUsed
( '_' );
}
}
}
}
@@
-56,63
+56,54
@@
class ApiFormatJson extends ApiFormatBase {
return 'application/json';
}
return 'application/json';
}
- /**
- * @deprecated since 1.25
- */
- public function getWantsHelp() {
- wfDeprecated( __METHOD__, '1.25' );
- // Help is always ugly in JSON
- return false;
- }
-
public function execute() {
$params = $this->extractRequestParams();
$opt = 0;
if ( $this->isRaw ) {
$opt |= FormatJson::ALL_OK;
public function execute() {
$params = $this->extractRequestParams();
$opt = 0;
if ( $this->isRaw ) {
$opt |= FormatJson::ALL_OK;
- $transform =
array()
;
+ $transform =
[]
;
} else {
switch ( $params['formatversion'] ) {
case 1:
$opt |= $params['utf8'] ? FormatJson::ALL_OK : FormatJson::XMLMETA_OK;
} else {
switch ( $params['formatversion'] ) {
case 1:
$opt |= $params['utf8'] ? FormatJson::ALL_OK : FormatJson::XMLMETA_OK;
- $transform =
array(
- 'BC' =>
array()
,
- 'Types' =>
array( 'AssocAsObject' => true )
,
+ $transform =
[
+ 'BC' =>
[]
,
+ 'Types' =>
[ 'AssocAsObject' => true ]
,
'Strip' => 'all',
'Strip' => 'all',
-
)
;
+
]
;
break;
case 2:
case 'latest':
$opt |= $params['ascii'] ? FormatJson::XMLMETA_OK : FormatJson::ALL_OK;
break;
case 2:
case 'latest':
$opt |= $params['ascii'] ? FormatJson::XMLMETA_OK : FormatJson::ALL_OK;
- $transform =
array(
- 'Types' =>
array( 'AssocAsObject' => true )
,
+ $transform =
[
+ 'Types' =>
[ 'AssocAsObject' => true ]
,
'Strip' => 'all',
'Strip' => 'all',
-
)
;
+
]
;
break;
default:
break;
default:
- $this->dieUsage( __METHOD__ .
-
': Unknown value for \'formatversion\'', 'unknownformatversion
' );
+ // Should have been caught during parameter validation
+
$this->dieDebug( __METHOD__, 'Unknown value for \'formatversion\'
' );
}
}
$data = $this->getResult()->getResultData( null, $transform );
$json = FormatJson::encode( $data, $this->getIsHtml(), $opt );
}
}
$data = $this->getResult()->getResultData( null, $transform );
$json = FormatJson::encode( $data, $this->getIsHtml(), $opt );
- //
Bug 66
776: wfMangleFlashPolicy() is needed to avoid a nasty bug in
+ //
T68
776: wfMangleFlashPolicy() is needed to avoid a nasty bug in
// Flash, but what it does isn't friendly for the API, so we need to
// work around it.
// Flash, but what it does isn't friendly for the API, so we need to
// work around it.
- if ( preg_match( '/\<\s*cross-domain-policy
\s*\>
/i', $json ) ) {
+ if ( preg_match( '/\<\s*cross-domain-policy
(?=\s|\>)
/i', $json ) ) {
$json = preg_replace(
$json = preg_replace(
- '/\<(\s*cross-domain-policy
\s*)\>/i', '\\u003C$1\\u003E
', $json
+ '/\<(\s*cross-domain-policy
(?=\s|\>))/i', '\\u003C$1
', $json
);
}
if ( isset( $params['callback'] ) ) {
$callback = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $params['callback'] );
# Prepend a comment to try to avoid attacks against content
);
}
if ( isset( $params['callback'] ) ) {
$callback = preg_replace( "/[^][.\\'\\\"_A-Za-z0-9]/", '', $params['callback'] );
# Prepend a comment to try to avoid attacks against content
- # sniffers, such as
bug 68
187.
+ # sniffers, such as
T70
187.
$this->printText( "/**/$callback($json)" );
} else {
$this->printText( $json );
$this->printText( "/**/$callback($json)" );
} else {
$this->printText( $json );
@@
-124,24
+115,24
@@
class ApiFormatJson extends ApiFormatBase {
return parent::getAllowedParams();
}
return parent::getAllowedParams();
}
- $ret = parent::getAllowedParams() +
array(
- 'callback' =>
array(
+ $ret = parent::getAllowedParams() +
[
+ 'callback' =>
[
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-callback',
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-callback',
-
)
,
- 'utf8' =>
array(
+
]
,
+ 'utf8' =>
[
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-utf8',
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-utf8',
-
)
,
- 'ascii' =>
array(
+
]
,
+ 'ascii' =>
[
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-ascii',
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-ascii',
-
)
,
- 'formatversion' =>
array(
- ApiBase::PARAM_TYPE =>
array( 1, 2, 'latest' )
,
+
]
,
+ 'formatversion' =>
[
+ ApiBase::PARAM_TYPE =>
[ 1, 2, 'latest' ]
,
ApiBase::PARAM_DFLT => 1,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-formatversion',
ApiBase::PARAM_DFLT => 1,
ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-formatversion',
-
)
,
-
)
;
+
]
,
+
]
;
return $ret;
}
}
return $ret;
}
}