From 79f79a356ca764d3ccfdce63c849542975dfd071 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Thu, 29 Mar 2012 13:13:23 +0000 Subject: [PATCH] trigger http error when non-text content is requested using action=raw --- includes/actions/RawAction.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 2dcc3875a3..1cac44ca5b 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -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(); } } -- 2.20.1