Add error checking for file argument
authorMark A. Hershberger <mah@everybody.org>
Thu, 12 Nov 2015 22:15:07 +0000 (17:15 -0500)
committerMark A. Hershberger <mah@everybody.org>
Thu, 12 Nov 2015 22:15:07 +0000 (17:15 -0500)
If the user ignorantly passes in ".", this will fail.

Change-Id: I1128945b7277ce7b3da27eb30b2dfbbf644c9d38

maintenance/convertExtensionToRegistration.php

index 3e86d8a..828507b 100644 (file)
@@ -79,7 +79,12 @@ class ConvertExtensionToRegistration extends Maintenance {
                        $$var = array();
                }
                unset( $var );
-               require $this->getArg( 0 );
+               $arg = $this->getArg( 0 );
+               if ( !is_file( $arg ) ) {
+                       $this->error( "$arg is not a file.", true );
+               }
+               require $arg;
+               unset( $arg );
                // Try not to create any local variables before this line
                $vars = get_defined_vars();
                unset( $vars['this'] );