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

Plugin: onInitializePluginOptions(): first key with null value will disappear #2391

Closed
IrineSistiana opened this issue Dec 30, 2019 · 4 comments · Fixed by #2398
Closed

Plugin: onInitializePluginOptions(): first key with null value will disappear #2391

IrineSistiana opened this issue Dec 30, 2019 · 4 comments · Fixed by #2398

Comments

@IrineSistiana
Copy link

@IrineSistiana IrineSistiana commented Dec 30, 2019

Describe the bug
after plugin call saveChanges(options) , everything looks fine, config stored successfully, it's string can be seen in shadowscosk-android UI. For example, option1;option2;option3;arg4=value

but when loading saved config using onInitializePluginOptions(options: PluginOptions), key option1 disappeard. Only got option2;option3;arg4=value

first key with null value will always disappear.

option1;option2;option3;arg4=value -> option2;option3;arg4=value

first key has a string value won't disappear.

arg1=value;option2;option3;arg4=value -> arg1=value;option2;option3;arg4=value

Pluging version
1.3.1

shadowsocks-android version
4.8.7

@IrineSistiana

This comment has been minimized.

Copy link
Author

@IrineSistiana IrineSistiana commented Jan 4, 2020

PluginOptions(intent.getStringExtra(PluginContract.EXTRA_OPTIONS))

if (parseId) id = current.toString() else put(current.toString(), null)

Seems that first key with null value will be parsed as id rather than put into Map, when constructing PluginOptions for onInitializePluginOptions(options: PluginOptions)

setResult(Activity.RESULT_OK, Intent().putExtra(PluginContract.EXTRA_OPTIONS, options.toString()))

override fun toString(): String = toString(true)

But id is trimmed while saving

@Mygod

This comment has been minimized.

Copy link
Contributor

@Mygod Mygod commented Jan 4, 2020

Yeah this seems problematic (sorry about the delay). Feel free to submit a PR (or wait for me to get around to it). :)

@IrineSistiana

This comment has been minimized.

Copy link
Author

@IrineSistiana IrineSistiana commented Jan 4, 2020

Hi @Mygod

I'm not quite sure what the var id does.

It seems that the simplest fix is changing

constructor(options: String?) : this(options, true)

to constructor(options: String?) : this(options, false)

Submitting a PR is quite hard for me right now. I'm still struggling to set up a working development environment. So I can't test it =[

Mygod added a commit that referenced this issue Jan 4, 2020
@Mygod

This comment has been minimized.

Copy link
Contributor

@Mygod Mygod commented Jan 4, 2020

See #2398. You can also try to take this fix in your plugin app locally and see if it works. :)

Mygod added a commit that referenced this issue Jan 9, 2020
@Mygod Mygod mentioned this issue Jan 9, 2020
@madeye madeye closed this in #2398 Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.