jenkins-bot has submitted this change and it was merged.

Change subject: Add jsonp format and whietlist underscore in callback
......................................................................


Add jsonp format and whietlist underscore in callback

Underscore is needed in callback since e.g. jquery defaults
to callbacks containing it.

Change-Id: I962144e8a670cb869ef1bb0a2445e1d18efecf9a
---
M api/includes/ApiBase.php
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Jean-Frédéric: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: I962144e8a670cb869ef1bb0a2445e1d18efecf9a
Gerrit-PatchSet: 2
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.pro...@gmail.com>
Gerrit-Reviewer: Jean-Frédéric <jeanfrederic.w...@gmail.com>
Gerrit-Reviewer: Multichill <maar...@mdammers.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to