Per wikitech-l, run a bunch of URLs in the API output through wfExpandUrl(), so they...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 13 Jul 2011 01:27:07 +0000 (01:27 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 13 Jul 2011 01:27:07 +0000 (01:27 +0000)
includes/api/ApiParse.php
includes/api/ApiQuery.php
includes/api/ApiQueryExtLinksUsage.php
includes/api/ApiQueryExternalLinks.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQuerySiteinfo.php

index 1b0e940..9d2d95a 100644 (file)
@@ -353,7 +353,7 @@ class ApiParse extends ApiBase {
 
                        $entry['lang'] = $bits[0];
                        if ( $title ) {
-                               $entry['url'] = $title->getFullURL();
+                               $entry['url'] = wfExpandUrl( $title->getFullURL() );
                        }
                        $this->getResult()->setContent( $entry, $bits[1] );
                        $result[] = $entry;
@@ -435,7 +435,7 @@ class ApiParse extends ApiBase {
 
                                $title = Title::newFromText( "{$prefix}:{$title}" );
                                if ( $title ) {
-                                       $entry['url'] = $title->getFullURL();
+                                       $entry['url'] = wfExpandUrl( $title->getFullURL() );
                                }
 
                                $this->getResult()->setContent( $entry, $title->getFullText() );
index 844b66e..810fba1 100644 (file)
@@ -374,7 +374,7 @@ class ApiQuery extends ApiBase {
                        );
                        if ( $this->iwUrl ) {
                                $title = Title::newFromText( $rawTitleStr );
-                               $item['url'] = $title->getFullURL();
+                               $item['url'] = wfExpandUrl( $title->getFullURL() );
                        }
                        $intrwValues[] = $item;
                }
index 1a74394..3aec88f 100644 (file)
@@ -126,6 +126,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                                        ApiQueryBase::addTitleInfo( $vals, $title );
                                }
                                if ( $fld_url ) {
+                                       // We *could* run this through wfExpandUrl() but I think it's better to output the link verbatim, even if it's protocol-relative --Roan
                                        $vals['url'] = $row->el_to;
                                }
                                $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
@@ -183,7 +184,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                foreach ( $wgUrlProtocols as $p ) {
                        $protocols[] = substr( $p, 0, strpos( $p, ':' ) );
                }
-           return $protocols;
+               return $protocols;
        }
 
        public static function getProtocolPrefix( $protocol ) {
index 88d3258..85a1bcc 100644 (file)
@@ -86,6 +86,7 @@ class ApiQueryExternalLinks extends ApiQueryBase {
                                break;
                        }
                        $entry = array();
+                       // We *could* run this through wfExpandUrl() but I think it's better to output the link verbatim, even if it's protocol-relative --Roan
                        ApiResult::setContent( $entry, $row->el_to );
                        $fit = $this->addPageSubItem( $row->el_from, $entry );
                        if ( !$fit ) {
index 6244793..9addf36 100644 (file)
@@ -112,7 +112,7 @@ class ApiQueryIWLinks extends ApiQueryBase {
                        if ( !is_null( $params['url'] ) ) {
                                $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" );
                                if ( $title ) {
-                                       $entry['url'] = $title->getFullURL();
+                                       $entry['url'] = wfExpandUrl( $title->getFullURL() );
                                }
                        }
 
index 8114e8d..a1fa7ac 100644 (file)
@@ -370,7 +370,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        $vals['thumberror'] = $mto->toText();
                                }
                        }
-                       $vals['url'] = $file->getFullURL();
+                       $vals['url'] = wfExpandUrl( $file->getFullURL() );
                        $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
                }
 
index 707a24c..23ef920 100644 (file)
@@ -380,8 +380,8 @@ class ApiQueryInfo extends ApiQueryBase {
                }
 
                if ( $this->fld_url ) {
-                       $pageInfo['fullurl'] = $title->getFullURL();
-                       $pageInfo['editurl'] = $title->getFullURL( 'action=edit' );
+                       $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL() );
+                       $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ) );
                }
                if ( $this->fld_readable && $title->userCanRead() ) {
                        $pageInfo['readable'] = '';
index 4dd3495..66e151e 100644 (file)
@@ -106,7 +106,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
                        if ( $params['url'] ) {
                                $title = Title::newFromText( "{$row->ll_lang}:{$row->ll_title}" );
                                if ( $title ) {
-                                       $entry['url'] = $title->getFullURL();
+                                       $entry['url'] = wfExpandUrl( $title->getFullURL() );
                                }
                        }
                        ApiResult::setContent( $entry, $row->ll_title );
index 6ace164..2cd4825 100644 (file)
@@ -117,7 +117,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data = array();
                $mainPage = Title::newMainPage();
                $data['mainpage'] = $mainPage->getPrefixedText();
-               $data['base'] = $mainPage->getFullUrl();
+               $data['base'] = wfExpandUrl( $mainPage->getFullUrl() );
                $data['sitename'] = $GLOBALS['wgSitename'];
                $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
                $data['phpversion'] = phpversion();
@@ -284,7 +284,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( isset( $langNames[$row->iw_prefix] ) ) {
                                $val['language'] = $langNames[$row->iw_prefix];
                        }
-                       $val['url'] = $row->iw_url;
+                       $val['url'] = wfExpandUrl( $row->iw_url );
                        $val['wikiid'] = $row->iw_wikiid;
                        $val['api'] = $row->iw_api;
 
@@ -448,7 +448,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        protected function appendRightsInfo( $property ) {
                global $wgRightsPage, $wgRightsUrl, $wgRightsText;
                $title = Title::newFromText( $wgRightsPage );
-               $url = $title ? $title->getFullURL() : $wgRightsUrl;
+               $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl;
                $text = $wgRightsText;
                if ( !$text && $title ) {
                        $text = $title->getPrefixedText();