Skip to content

Fix profile JSON import broken by trailing newline#3244

Open
trulyliu wants to merge 1 commit intoshadowsocks:masterfrom
trulyliu:master
Open

Fix profile JSON import broken by trailing newline#3244
trulyliu wants to merge 1 commit intoshadowsocks:masterfrom
trulyliu:master

Conversation

@trulyliu
Copy link
Copy Markdown

@trulyliu trulyliu commented May 8, 2026

The gson→org.json migration in df4d65c wrapped the root-value read in while (JSONTokener.more()) process(nextValue()), but JSONTokener.more() reports true on trailing whitespace. Every JSON file ending with a newline (i.e. essentially every file) hits a second nextValue() call that runs off the end and throws JSONException, before finalize() persists the parsed profile.

Restore the pre-migration single-value semantic.

The gson→org.json migration in df4d65c wrapped the root-value
read in `while (JSONTokener.more()) process(nextValue())`, but
JSONTokener.more() reports true on trailing whitespace. Every
JSON file ending with a newline (i.e. essentially every file)
hits a second nextValue() call that runs off the end and throws
JSONException, before finalize() persists the parsed profile.

Restore the pre-migration single-value semantic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@trulyliu
Copy link
Copy Markdown
Author

trulyliu commented May 8, 2026

This PR fixes a bug in the latest version that prevents the import of JSON configuration files on TV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant