https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114601

Revision: 114601
Author:   daniel
Date:     2012-03-29 13:13:23 +0000 (Thu, 29 Mar 2012)
Log Message:
-----------
trigger http error when non-text content is requested using action=raw

Modified Paths:
--------------
    branches/Wikidata/phase3/includes/actions/RawAction.php

Modified: branches/Wikidata/phase3/includes/actions/RawAction.php
===================================================================
--- branches/Wikidata/phase3/includes/actions/RawAction.php     2012-03-29 
12:21:49 UTC (rev 114600)
+++ branches/Wikidata/phase3/includes/actions/RawAction.php     2012-03-29 
13:13:23 UTC (rev 114601)
@@ -132,11 +132,20 @@
                                $request->response()->header( "Last-modified: 
$lastmod" );
 
                                // Public-only due to cache headers
-                               $text = $rev->getText();
+                               $content = $rev->getContent();
+
+                               if ( !$content instanceof TextContent ) {
+                                       wfHttpError( 406, "Not Acceptable", 
"The requeste page uses the content model `"
+                                                                               
                                . $content->getModelName() . "` which is not 
supported via this interface." );
+                                       die();
+                               }
+
                                $section = $request->getIntOrNull( 'section' );
                                if ( $section !== null ) {
-                                       $text = $wgParser->getSection( $text, 
$section );
+                                       $content = $content->getSection( 
$section );
                                }
+
+                               $text = $content->getNativeData();
                        }
                }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to