Skip to content

Issue with directory separators / file paths #118

Description

@pixelbrad

Hello,

I'm working on a project locally on a Windows machine and had to test Sucuri. I discovered Sucuri is generating a PHP error before WordPress has fully initialized, even before debug logging is set.

In the function htaccess (sucuri-scanner/src/hardening.lib.php:191), $folder is passed in, but it has all forward slashes (for example: F:/sites/my-bedrock-project/web/app/sucuri). On line 193, we're trying to replace ABSPATH in the $folder string with nothing. The problem is, ABSPATH uses a mix of (mostly) backslashes and forward slashes: F:\sites\my-bedrock-project\web\wp/. Ultimately, the htaccess function returns a string like this:

F:\sites\my-bedrock-project\web\wp//F:/sites/my-bedrock-project/web/app/sucuri/.htaccess

I discovered this by digging in to why my WP admin dashboard had the class php-error but no errors were displayed or logged to the debug log. In wordpress/wp-admin/admin-header.php:197, error_get_last is called, and by viewing its output, it tells me Sucuri is trying to open a file it can't open:

fopen(F:\sites\my-bedrock-project\web\wp//F:/sites/my-bedrock-project/web/app/sucuri/.htaccess): failed to open stream: No such file or directory.

sucuri-scanner/src/hardening.lib.php is trying to open that file on line 98.

Extra Information

  • This is a Bedrock project
  • I have set the constant SUCURI_DATA_STORAGE to WP_CONTENT_DIR . '/sucuri'. I'm not sure this problem is present without this constant.
  • WP_CONTENT_DIR, at this point during execution, evaluates to F:\sites\my-bedrock-project/web/app
  • The system paths in this message are exact copies of what I've pulled out of the debugger - the mish-mash between forward and backward slashes is not me making typos.
  • I am developing on Windows 10, using Laragon w/ Apache and PHP 7.3.20, debugging with Xdebug and PhpStorm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions