Skip to content

Commit

Permalink
Don't warn about .htaccess file when --include-root is used (#112)
Browse files Browse the repository at this point in the history
* Don't warn about .htaccess file when --include-root is used

* add .htaccess file to tests

* update test output for htaccess
  • Loading branch information
paulschreiber authored Jun 1, 2023
1 parent acda510 commit 5da44c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions features/checksum-core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ Feature: Validate checksums for WordPress install

Scenario: Verify core checksums when extra files are included in WordPress root and --include-root is passed
Given a WP install
And a .htaccess file:
"""
# BEGIN WordPress
"""
And a extra-file.php file:
"""
hello world
Expand All @@ -169,6 +173,10 @@ Feature: Validate checksums for WordPress install
"""
Warning: File should not exist: extra-file.php
"""
And STDERR should not contain:
"""
Warning: File should not exist: .htaccess
"""
And STDERR should not contain:
"""
Warning: File should not exist: wp-content/unknown-file.php
Expand Down
2 changes: 1 addition & 1 deletion src/Checksum_Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function __invoke( $args, $assoc_args ) {
*/
protected function filter_file( $filepath ) {
if ( true === $this->include_root ) {
return ( 1 !== preg_match( '/^(wp-config\.php$|wp-content\/)/', $filepath ) );
return ( 1 !== preg_match( '/^(\.htaccess$|wp-config\.php$|wp-content\/)/', $filepath ) );
}

return ( 0 === strpos( $filepath, 'wp-admin/' )
Expand Down

0 comments on commit 5da44c9

Please sign in to comment.