From e5d1fd1279b6a6a8e3ed3da6ba4e476c23a980da Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Sun, 8 May 2016 13:14:56 +0100 Subject: [PATCH] Match last ] in line when parsing Section header I have a config.ini where section names can contain "]", which leads to parse errors. While proper support for quoting would be best (issue #32) simply matching the last "]" rather than the first helps in this case. --- parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.go b/parser.go index 1c1bf91..a52bd04 100644 --- a/parser.go +++ b/parser.go @@ -258,7 +258,7 @@ func (f *File) parse(reader io.Reader) (err error) { // Section if line[0] == '[' { // Read to the next ']' (TODO: support quoted strings) - closeIdx := bytes.IndexByte(line, ']') + closeIdx := bytes.LastIndexByte(line, ']') if closeIdx == -1 { return fmt.Errorf("unclosed section: %s", line) }