Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/186327

Change subject: conf: Clean up highlight.php and fix http-redirect bug
......................................................................

conf: Clean up highlight.php and fix http-redirect bug

Follows-up 26929a2f2e4.

https://noc.wikimedia.org/conf/highlight.php redirects to HTTP
due to a missing 'else' statement in the $protocol logic. So the
second block always executes due to the second block just being
an unnamed block that unconditionally executes.

Since we hardcode HTTP 1.1 and because this is primarily a
developer endpoint, just use relative urls for the redirect.

This way it also works locally for developers that have
mediawiki-config itself mounted on a local webserver as it now
is relative to the path instead of hardcoding /conf.

It previously allowed for the hostname to be overridden (why?)
via SERVER_NAME, but did not the path (via e.g. SCRIPT_FILENAME).

Change-Id: Ie15eec3a90fa0a29b965387ee89e74131117fb71
---
M docroot/noc/conf/highlight.php
1 file changed, 8 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/27/186327/1

diff --git a/docroot/noc/conf/highlight.php b/docroot/noc/conf/highlight.php
index d6cf8ed..b863766 100644
--- a/docroot/noc/conf/highlight.php
+++ b/docroot/noc/conf/highlight.php
@@ -33,26 +33,22 @@
                break;
        }
 }
-if ( PHP_SAPI !== 'cli' ) { // Don't run if executing unit tests
+// Don't run if executing unit tests
+if ( PHP_SAPI !== 'cli' ) {
        ob_start( 'ob_gzhandler' );
        header( 'Content-Type: text/html; charset=utf-8' );
 }
 
 if ( !$selectedFilePath ) {
        if( $selectedFileName === null ){
-               // No parameter file given, e.g. if you go to this file 
directly, redirect to overview
-               if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ){
-                       $protocol = "https";
-               } {
-                       $protocol = "http";
-               }
-               header( "HTTP/1.1 302 Found" );
-               header( "Location: ". $protocol . "://" . $_SERVER[ 
'SERVER_NAME'] ."/conf/index.php" );
-               echo $protocol . "://" . $_SERVER[ 'SERVER_NAME'] 
."/conf/index.php";
+               // If no 'file' is given (e.g. accessing this file directly), 
redirect to overview
+               header( 'HTTP/1.1 302 Found' );
+               header( 'Location: ./index.php' );
+               echo '<a href="./index.php">Redirect</a>';
                exit;
        } else {
-               // Parameter file IS given, but for whatever reason no filename 
given or filename not existing in this directory
-               $hlHtml = "<pre>No valid, whitelisted filename in parameter 
\"file\" given.</pre>";
+               // Parameter file is given, but not existing in this directory
+               $hlHtml = '<pre>Invalid filename given.</pre>';
        }
 } else {
        // Follow symlink

-- 
To view, visit https://gerrit.wikimedia.org/r/186327
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie15eec3a90fa0a29b965387ee89e74131117fb71
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

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

Reply via email to