(bug 44449) Add siprop=protocols to SiteInfo API
authorMark Holmquist <mtraceur@member.fsf.org>
Thu, 14 Feb 2013 23:06:15 +0000 (15:06 -0800)
committerMark Holmquist <mtraceur@member.fsf.org>
Thu, 14 Feb 2013 23:06:15 +0000 (15:06 -0800)
The existing method for getting allowed URL protocols will not help Parsoid,
so we're adding a new API call that will help us fix bug 44449.

Change-Id: I5fd130cb30313f8e8a376ff0146195f2264e8e0e

includes/api/ApiQuerySiteinfo.php

index 3ed0113..593d6e7 100644 (file)
@@ -96,6 +96,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'variables':
                                        $fit = $this->appendVariables( $p );
                                        break;
+                               case 'protocols':
+                                       $fit = $this->appendProtocols( $p );
+                                       break;
                                default:
                                        ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -549,6 +552,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $variables );
        }
 
+       public function appendProtocols( $property ) {
+               global $wgUrlProtocols;
+               $this->getResult()->setIndexedTagName( $wgUrlProtocols, 'p' );
+               return $this->getResult()->addValue( 'query', $property, $wgUrlProtocols );
+       }
+
        private function formatParserTags( $item ) {
                return "<{$item}>";
        }
@@ -601,6 +610,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'functionhooks',
                                        'showhooks',
                                        'variables',
+                                       'protocols',
                                )
                        ),
                        'filteriw' => array(
@@ -638,6 +648,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' functionhooks         - Returns a list of parser function hooks',
                                ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
                                ' variables             - Returns a list of variable IDs',
+                               ' protocols             - Returns a list of protocols that are allowed in external links.',
                        ),
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',