Repository navigation
fix(config): exclude inline comments and trailing whitespace from values - #6190
Closed
Dev-next-gen wants to merge 1 commit into
Closed
Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
parse_option found the end of the value without the comment or trailing whitespace (endc), but copied the value up to the end of the line. A line such as `upnp = enabled # comment` produced "enabled ", which to_bool treats as false, and `min_threads = 2 # comment` was parsed as 4.
Contributor
Author
|
|
Member
|
I'm planning to rewrite the config system soon, and this won't apply... so, closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
parse_optioncomputesendc, the end of the value without an inline comment or trailing whitespace, but only uses it to find the=. The value itself is copied up to the end of the line, andto_stringstrips the#comment but keeps the spaces before it. Insunshine.conf:upnp = enabled # open portsgives"enabled ", whichto_booltreats as false, so UPnP stays offmin_threads = 2 # coresis parsed as4, becausefrom_viewreads the trailing space as a digitport = 48000 # webgives a number outside the allowed range, so the port silently stays at the defaultport = 48000(a trailing space, no comment) does the sameThe fix copies a single-line value up to
endc. Lists still end at the closing bracket found byskip_list, as before. The same values are returned by/api/config, which also reads the file throughparse_config.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
Added
ConfigParsingTest.ValuesExcludeTrailingCommentsAndWhitespace(inline comment, trailing spaces and tab, CRLF line, and a list followed by a comment).I did not build
test_sunshinefor this change. Instead I compiledsrc/utility.htogether withparse_configand its helpers,to_boolandparse_config_integercopied unchanged fromsrc/config.cpp(master, then this branch) with g++ 14 on Linux, and fed them the same input as the new test:upnpis"enabled "andto_boolreturns false,portis"47989 \t"and parses as4798701,encoderis"software\t",min_threads = 2 # coresparses as4)[a, b]in both casesType of Change
Checklist
AI Usage
See our AI usage policy.
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.