wp-cli / wp-config-transformer

Programmatically edit a wp-config.php file
MIT License
81 stars 25 forks source link

fix new_src substitution #19

Closed andreamk closed 5 years ago

andreamk commented 5 years ago

In the case of the char $ preceded by \ the substitution didn't work correctly.

I have improved the simple addition of \ With a regex that adds \ in case the character $ is not preceded by an odd number of \

Code example

$dbpass = '$3_\\\$56[Plac\\$1eholder]xxx$10';
$confTransformer->update('constant', 'DB_PASSWORD', $dbpass, array('raw' => false));

These bugs we can find them because we use this library in the Duplicator plugin and we are dealing with millions of different passwords with every possible character sequence.

schlessera commented 5 years ago

@andreamk Can you add a test that verifies the problematic behavior?

schlessera commented 5 years ago

@andreamk Are you up for writing a test for this PR?

andreamk commented 5 years ago

Hi @schlessera Sorry, but I hadn't read the other notification.

Yes, the develop the tests so I understand how to do it. I went ahead and my changes fix only partially the problem I close the PR and I create a new one with the update.