From 96a8592f111d50a290c86ad5d779928b8524aeb4 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Tue, 27 Jun 2017 09:21:29 +0000 Subject: [PATCH] Use a 301 instead of 500 for PATH_INFO in api Bug: T128209 Change-Id: I6145fcb1febcb189a397bb1822d3e56c6dae6ce1 --- api.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api.php b/api.php index 668228a..1b596eb 100644 --- a/api.php +++ b/api.php @@ -47,7 +47,9 @@ if ( !$wgRequest->checkUrlExtension() ) { // Pathinfo can be used for stupid things. We don't support it for api.php at // all, so error out if it's present. if ( isset( $_SERVER['PATH_INFO'] ) && $_SERVER['PATH_INFO'] != '' ) { - header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Path info not allowed', true, 500 ); + $correctUrl = wfAppendQuery( wfScript( 'api' ), $wgRequest->getValues() ); + $correctUrl = wfExpandUrl( $correctUrl, PROTO_CANONICAL ); + header( "Location: $correctUrl", true, 301 ); echo 'This endpoint does not support "path info", i.e. extra text between "api.php"' . 'and the "?". Remove any such text and try again.'; die( 1 ); -- 1.9.5 (Apple Git-50.3)