Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of escaped quotes #16

Merged
merged 5 commits into from Apr 1, 2019

Conversation

@andreamk
Copy link
Contributor

commented Mar 16, 2019

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

andreamk added some commits Mar 16, 2019

Update WPConfigTransformer.php
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
Update WPConfigTransformer.php
prevent greedy match for empty defines values
@schlessera

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

@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:

  • the fix is the correct one, and
  • we won't reintroduce a regression for this later on.

@schlessera schlessera added the bug label Mar 16, 2019

@andreamk

This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2019

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

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

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

@schlessera schlessera changed the title Update WPConfigTransformer.php Fix parsing of escaped quotes Apr 1, 2019

@andreamk andreamk requested a review from wp-cli/committers as a code owner Apr 1, 2019

@schlessera

This comment has been minimized.

Copy link
Member

commented Apr 1, 2019

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

@schlessera schlessera added this to the 1.2.5 milestone Apr 1, 2019

@schlessera schlessera merged commit 46c6c36 into wp-cli:master Apr 1, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@schlessera

This comment has been minimized.

Copy link
Member

commented Apr 1, 2019

Thanks for the PR, @andreamk !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.