Bug: incorrect handling of root path containing backslashes

Viewing 3 posts - 1 through 3 (of 3 total)
#193327

Tim B
Participant

Hi,

I have found the following bug which likely only affects Windows servers where file paths can contain backslashes. See below for temporary fix.

Symptoms:
After installing free version of plugin (v3.2.86) on a Windows development machine, an absolute path is shown in the editable part of the File Browser Root field in Settings – Access Settings. Changing it to a relative path (e.g. wp-content/whatever) and pressing Save Settings has no effect. The incorrect handling of this path results in the Asset Manager showing no files or folders, and files cannot be uploaded.

Cause:
The File Browser Root path is stored in the option _wpdm_file_browser_root and (for me) contains backslashes.
However, the method get_home_path() returns a path containing forward slashes.
Therefore, the string replacement str_replace(get_home_path(), “”, $fbRoot) in AssetManager.php line 44 fails to make a relative path as intended.

Temporary fix:
Replace any backslashes with forward slashes before using the value of the _wpdm_file_browser_root option.

AssetManager.php line 43:
$fbRoot = str_replace(“\\”, “/”, get_option(‘_wpdm_file_browser_root’)); /* Fixed */

Basic.php line 46:
value=”<?php echo str_replace(get_home_path(), “”, str_replace(“\\”, “/”, get_option(‘_wpdm_file_browser_root’, dirname(UPLOAD_DIR)))); /* Fixed */ ?>”

Basic.php line 51:
onclick=”jQuery(‘#_wpdm_file_browser_root’).val(‘<?php echo str_replace(get_home_path(), “”, str_replace(“\\”, “/”, get_option(‘_wpdm_file_browser_root’, dirname(UPLOAD_DIR))));/* Fixed */ ?>’); “><i

FileSystem.php line 870:
$file_browser_root = str_replace(“\\”, “/”, get_option(‘_wpdm_file_browser_root’, ”)); /* Fixed */

For a more permanent fix, it might be advisable to use standard methods such as path_join() to manipulate file paths instead of string concatenation and replacement operations.

Regards,
Tim

#193329

Tahasin
Moderator

Hello, Tim B

I hope you are doing well, and thanks for contacting us.

We are investigating the issue and will let you know about it shortly.

Regards

#193338

Tahasin
Moderator

We appreciate your keen observation and willingness to report the issue, which results in a significant impact on the improvement of our plugin.
This bug will be fixed in the next update.

Regards

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.