Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ Feature: Scaffold plugin unit tests
"""
And the return code should be 1

When I try `wp scaffold plugin-tests my-plugin/`
Then STDERR should be:
"""
Error: Invalid plugin slug specified. The slug cannot end with a slash.
"""
And the return code should be 1

When I try `wp scaffold plugin-tests my-plugin\\`
Then STDERR should be:
"""
Error: Invalid plugin slug specified. The slug cannot end with a slash.
"""
And the return code should be 1

Scenario: Scaffold plugin tests with invalid directory
Given a WP install
And I run `wp scaffold plugin hello-world --skip-tests`
Expand Down
14 changes: 14 additions & 0 deletions features/scaffold-theme-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ Feature: Scaffold theme unit tests
"""
And the return code should be 1

When I try `wp scaffold theme-tests t12child/`
Then STDERR should be:
"""
Error: Invalid theme slug specified. The slug cannot end with a slash.
"""
And the return code should be 1

When I try `wp scaffold theme-tests t12child\\`
Then STDERR should be:
"""
Error: Invalid theme slug specified. The slug cannot end with a slash.
"""
And the return code should be 1

Scenario: Scaffold theme tests with invalid directory
When I try `wp scaffold theme-tests twentytwelve --dir=non-existent-dir`
Then STDERR should be:
Expand Down
4 changes: 4 additions & 0 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,10 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
if ( in_array( $slug, [ '.', '..' ], true ) ) {
WP_CLI::error( "Invalid {$type} slug specified. The slug cannot be '.' or '..'." );
}
// Reject slugs ending with slashes to prevent corrupted bootstrap.php files.
if ( '/' === substr( $slug, -1 ) || '\\' === substr( $slug, -1 ) ) {
Comment thread
swissspidy marked this conversation as resolved.
Outdated
WP_CLI::error( "Invalid {$type} slug specified. The slug cannot end with a slash." );
}
Comment thread
swissspidy marked this conversation as resolved.
if ( 'theme' === $type ) {
$theme = wp_get_theme( $slug );
if ( $theme->exists() ) {
Expand Down