trigger http error when non-text content is requested using action=raw
authorDaniel Kinzler <daniel.kinzler@wikimedia.de>
Thu, 29 Mar 2012 13:13:23 +0000 (13:13 +0000)
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>
Wed, 4 Apr 2012 18:00:31 +0000 (20:00 +0200)
includes/actions/RawAction.php

index 2dcc387..1cac44c 100644 (file)
@@ -132,11 +132,20 @@ class RawAction extends FormlessAction {
                                $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();
                        }
                }