1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 18:00:55 +00:00

Merge pull request #3292 from SongLiangChen/master

Read over 4096 length values
This commit is contained in:
astaxie 2018-09-30 16:03:45 +08:00 committed by GitHub
commit ea9c5822e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,15 +78,37 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e
} }
} }
section := defaultSection section := defaultSection
tmpBuf := bytes.NewBuffer(nil)
for { for {
line, _, err := buf.ReadLine() tmpBuf.Reset()
if err == io.EOF {
shouldBreak := false
for {
tmp, isPrefix, err := buf.ReadLine()
if err == io.EOF {
shouldBreak = true
break
}
//It might be a good idea to throw a error on all unknonw errors?
if _, ok := err.(*os.PathError); ok {
return nil, err
}
tmpBuf.Write(tmp)
if isPrefix {
continue
}
if !isPrefix {
break
}
}
if shouldBreak {
break break
} }
//It might be a good idea to throw a error on all unknonw errors?
if _, ok := err.(*os.PathError); ok { line := tmpBuf.Bytes()
return nil, err
}
line = bytes.TrimSpace(line) line = bytes.TrimSpace(line)
if bytes.Equal(line, bEmpty) { if bytes.Equal(line, bEmpty) {
continue continue