Skip to content

Commit

Permalink
Merge pull request gugemichael#5 from vinllen/bugfix-row-length-limit…
Browse files Browse the repository at this point in the history
…-4096

Bugfix row length limit 4096
  • Loading branch information
gugemichael authored Apr 13, 2021
2 parents 647883f + 13593b4 commit ccb2ff0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,32 @@ func (loader *ConfigLoader) extractAsList(value string) ([]string, error) {
}

func readAllLines(reader bufio.Reader) (lines []string) {
buffered := make([]byte, 0, 8192)
for {
if buf, end, err := reader.ReadLine(); end || err != nil {
if buf, isPrefix, err := reader.ReadLine(); err != nil {
break
} else if isPrefix {
buffered = append(buffered, buf...)
} else {
if len(buffered) != 0 {
buffered = append(buffered, buf...)
buf = buffered
}
line := strings.Trim(string(buf), " \r\n")
if len(line) != 0 && !isComment(line) {
lines = append(lines, line)
}

if len(buffered) != 0 {
buffered = make([]byte, 0, 8192)
}
}
}

if len(buffered) != 0 {
line := strings.Trim(string(buffered), " \r\n")
if len(line) != 0 && !isComment(line) {
lines = append(lines, line)
}
}
return lines
Expand Down

0 comments on commit ccb2ff0

Please sign in to comment.