paypal / butterfly

Application transformation tool
https://paypal.github.io/butterfly/
MIT License
47 stars 50 forks source link

Butterfly CLI should allow escaped semicolons and equals as extension property value when passed using -p #360

Closed fabiocarvalho777 closed 3 years ago

fabiocarvalho777 commented 3 years ago

See issue #167 for context. Currently any semicolon passed to Butterfly CLI using -p will always be used to separate properties. Similarly, equals will always be used to separate property name from property value.

However, both should also be allowed as property value, as long as escaped when using -p.

badalsarkar commented 3 years ago

Hello, I would like to work on this issue. I am assuming the following scenario- -pkey1=value1;key2=value2 should return key1 = value1 and key2 = value2 -pkey1=value\;1;key2=value\;2 should return key1 = value;1 and key2 = value;2 -pkey1=value\=1;key2=value\=2 should return key1 = value=1 and key2 = value=2

Please let me know if I am getting it right.

fabiocarvalho777 commented 3 years ago

Hello @badalsarkar Yes, you got it right. Thanks!

badalsarkar commented 3 years ago

Hi @fabiocarvalho777 I have figured out a solution. Changing try (StringReader stringReader = new StringReader(inlineProperties.replace(';', '\n'))) {

in this file to

try (StringReader stringReader = new StringReader(inlineProperties.replaceAll("(?<!\\\\);", "\n"))) {

should produce the desired result.

But how do I go about testing it? Should I add new test and in which file?

Thanks.

fabiocarvalho777 commented 3 years ago

@badalsarkar please, add a unit test class named ButterflyCliRunnerTest here and add your tests there.

Thanks!!

fabiocarvalho777 commented 3 years ago

@badalsarkar I have just merged your PR. Thank you very much for your contribution :-)

badalsarkar commented 3 years ago

@fabiocarvalho777 , it was great to contribute. Thank you.