Skip to content

wrong value if read slice of strings with commas #160

@sattellite

Description

@sattellite

I caught a problem with slice values that have commas in them. The line is divided by commas, and instead of one value in a slice, you get several values. This happens with both JSON and TOML.

type Config struct {
  Section struct {
    ID []string
  }
}
{"section": {"id": ["a","b", "c,d"]}}
[section]
id = ["a", "b", "c,d"]

Result slice of Config.Section.ID will have 4 values: "a", "b", "c" and "d".

The problem is related to the way values in slices are filled. *Loader.setSlice accepts a string formed with a comma separator. I suggest using a more complex separator so that the chance of encountering it in a row is lower. For example: ",;:|".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions