reject . and .. from scaffold *

This commit is contained in:
miya0001 2016-12-15 16:01:17 +09:00
parent c2781c052d
commit 0558dcc916

View file

@ -239,6 +239,10 @@ class Scaffold_Command extends WP_CLI_Command {
$url = "http://underscores.me";
$timeout = 30;

if ( in_array( $theme_slug, array( '.', '..' ) ) ) {
WP_CLI::error( "Invalid theme slug specified." );
}

$data = wp_parse_args( $assoc_args, array(
'theme_name' => ucfirst( $theme_slug ),
'author' => "Me",
@ -354,6 +358,10 @@ class Scaffold_Command extends WP_CLI_Command {
function child_theme( $args, $assoc_args ) {
$theme_slug = $args[0];

if ( in_array( $theme_slug, array( '.', '..' ) ) ) {
WP_CLI::error( "Invalid theme slug specified." );
}

$data = wp_parse_args( $assoc_args, array(
'theme_name' => ucfirst( $theme_slug ),
'author' => "Me",
@ -495,6 +503,10 @@ class Scaffold_Command extends WP_CLI_Command {
$plugin_name = ucwords( str_replace( '-', ' ', $plugin_slug ) );
$plugin_package = str_replace( ' ', '_', $plugin_name );

if ( in_array( $plugin_slug, array( '.', '..' ) ) ) {
WP_CLI::error( "Invalid plugin slug specified." );
}

$data = wp_parse_args( $assoc_args, array(
'plugin_slug' => $plugin_slug,
'plugin_name' => $plugin_name,
@ -662,6 +674,9 @@ class Scaffold_Command extends WP_CLI_Command {

if ( ! empty( $args[0] ) ) {
$slug = $args[0];
if ( in_array( $slug, array( '.', '..' ) ) ) {
WP_CLI::error( "Invalid {$type} slug specified." );
}
if ( 'theme' === $type ) {
$theme = wp_get_theme( $slug );
if ( $theme->exists() ) {