sync: read UTF8 string, don't expect sane encoding from imported files, just force it

This commit is contained in:
nemunaire 2018-05-12 12:15:00 +02:00
commit 492ab72dcd
2 changed files with 9 additions and 1 deletions

View file

@ -81,7 +81,13 @@ func getFileContent(i Importer, URI string) (string, error) {
if err := getFile(i, URI, bufio.NewWriter(io.Writer(&cnt))); err != nil {
return "", err
} else {
return strings.TrimSpace(cnt.String()), nil
// Ensure we read UTF-8 content.
buf := make([]rune, 0)
for b, _, err := cnt.ReadRune(); err == nil; b, _, err = cnt.ReadRune() {
buf = append(buf, b)
}
return strings.TrimSpace(string(buf)), nil
}
}