wp-cli / wp-config-transformer

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

Fix parsing of escaped quotes #16

Closed andreamk closed 5 years ago

andreamk commented 5 years ago

I have updated the regexes so that it executes a correct match in the case of quotas in the constant string.

For example define ('DB_PASSWORD', "aaaa\" aaaa "); executed a wrong match

schlessera commented 5 years ago

@andreamk, can you add a test that demonstrates the faulty behavior and make sure that the test fails without the above change and then succeeds with the change? This way, we can make sure that:

andreamk commented 5 years ago

I will do it but I have to find the time. For the moment I am attaching the screenshots of the regex online before and after my changes.

before

after

schlessera commented 5 years ago

@andreamk Just let me know if I should help out with adding the test.

schlessera commented 5 years ago

I added a quick set of tests to check for quotes within quotes.

schlessera commented 5 years ago

Thanks for the PR, @andreamk !