amElnagdy / salt-shaker

Salt Shaker allows you to change WP security keys and salt manually and automatically.
https://nagdy.net/salt-shaker/
9 stars 3 forks source link

When a backslash appears at the end of generated keys #31

Open zixben opened 5 days ago

zixben commented 5 days ago

Describe the bug When Salt Shaker generates a new key, there is a chance that the key includes a backslash ( \ ) as the final character. This causes the wp-config.php file to be improperly escaped, leading to site failure with a fatal error.

This issue arises because the key generation process does not account for edge cases where a backslash appears at the end of the string. While rare, this can cause significant disruption.

To Reproduce Steps to reproduce the behavior:

Use Salt Shaker to generate new keys automatically (either manually trigger or wait for scheduled regeneration).
If a backslash appears as the final character in a key, observe that the site becomes inaccessible.
Check the wp-config.php file and see that the string containing the backslash is improperly escaped.

Expected behavior Keys should be generated such that they are valid and do not include a trailing backslash to avoid escaping issues in the wp-config.php file.

amElnagdy commented 4 days ago

Thank you, @zixben for reporting this.

When Salt Shaker generates a new key, there is a chance that the key includes a backslash ()

To confirm, you mean this backslash \ and not the parentheses ()? Am I correct?

zixben commented 4 days ago

You are welcome, and thank you for your prompt response.

Yes, for some reason, the backslash ( \ ) didn’t display properly in the text above. I’ve updated the reference by adding spaces between the parentheses to clarify.

To confirm, the issue specifically refers to the backslash ( \ ) and not the parentheses.

Here’s a short example for clarity: define('AUTH_KEY', 'I included only the last 3 characters of the key that caused the issue ---> Lq\ <----');

In this case, the final backslash escapes the closing single quotation mark, causing a syntax error.

Let me know if you need further details!

amElnagdy commented 4 days ago

Thank you, @zixben! It is super clear now. I'll include a fix for this one in the next release.