Skip to content

struct: escape delimiter in string slices on ReflectFrom - #402

Merged
unknwon merged 2 commits into
go-ini:v1from
team-humaki:quote-comma-slices
Nov 11, 2026
Merged

unknwon merged 2 commits into
go-ini:v1from
team-humaki:quote-comma-slices

Conversation

@team-humaki

Copy link
Copy Markdown

ReflectFrom joined []string with the field delimiter and did not escape delimiter characters inside an element. Values like Test with comma, Three were then split on load.

Escape \ then the delimiter when writing string slices, using the same rules Key.Strings already applies on read (value1\, value2 in testdata). Round-trip of a slice that contains the delimiter now preserves elements.

Fixes #348

team-humaki and others added 2 commits November 11, 2026 20:29
Escaping changes what ReflectFrom writes for elements that contain the
delimiter, such as WireGuard AllowedIPs, which other readers don't
unescape. Default output stays as before.
@unknwon
unknwon merged commit 906cb6f into go-ini:v1 Nov 11, 2026
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.

using []string in a struct goes wrong if any of the strings contains a comma ','

2 participants