Lokal Profil has uploaded a new change for review. https://gerrit.wikimedia.org/r/316223
Change subject: Add jsonp format and whitlist undercore in callback ...................................................................... Add jsonp format and whitlist undercore in callback Underscore is needed in callback since jquery uses it Change-Id: I962144e8a670cb869ef1bb0a2445e1d18efecf9a --- M api/includes/ApiBase.php 1 file changed, 8 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/tools/heritage refs/changes/23/316223/1 diff --git a/api/includes/ApiBase.php b/api/includes/ApiBase.php index fa63875..8fce128 100644 --- a/api/includes/ApiBase.php +++ b/api/includes/ApiBase.php @@ -36,8 +36,8 @@ $params = [ 'format' => [ ApiBase::PARAM_DFLT => 'xmlfm', ApiBase::PARAM_TYPE => $dbMiserMode - ? [ 'json', 'xml', 'xmlfm' ] - : [ 'csv', 'dynamickml', 'kml', 'gpx', 'googlemaps', 'poi', 'html', 'htmllist', 'layar', 'json', 'osm', 'xml', 'xmlfm', 'wikitable' ] ], + ? [ 'json', 'jsonp', 'xml', 'xmlfm' ] + : [ 'csv', 'dynamickml', 'kml', 'gpx', 'googlemaps', 'poi', 'html', 'htmllist', 'layar', 'json', 'osm', 'xml', 'xmlfm', 'wikitable', 'jsonp' ] ], 'callback' => [ ApiBase::PARAM_DFLT => false, ApiBase::PARAM_TYPE => 'callback' ], 'limit' => [ ApiBase::PARAM_MIN => 0, ApiBase::PARAM_MAX => $dbMiserMode ? 500 : 5000, ApiBase::PARAM_DFLT => 100, ApiBase::PARAM_TYPE => 'integer' ], @@ -98,7 +98,7 @@ $cache[$name] = $allowed[$name][ApiBase::PARAM_DFLT]; } } elseif ( $p == 'callback' ) { - if ( !preg_match( '/^[A-Za-z0-9]+$/', $_GET[$name] ) ) { + if ( !preg_match( '/^[A-Za-z0-9_]+$/', $_GET[$name] ) ) { $this->setError( 'bad-callback-name', $_GET[$name] ); $cache[$name] = $allowed[$name][ApiBase::PARAM_DFLT]; } else { @@ -205,7 +205,11 @@ * @return FormatBase */ function getFormatter() { - $formatter = "Format" . ucfirst( $this->getParam( 'format' ) ); + if ( $this->getParam( 'format' ) == 'jsonp' ) { + $formatter = "FormatJson"; + } else { + $formatter = "Format" . ucfirst( $this->getParam( 'format' ) ); + } return new $formatter( $this ); } -- To view, visit https://gerrit.wikimedia.org/r/316223 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I962144e8a670cb869ef1bb0a2445e1d18efecf9a Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/heritage Gerrit-Branch: master Gerrit-Owner: Lokal Profil <lokal.pro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits