Fix quoted values check

This commit is contained in:
Matias Anaya
2017-03-21 18:35:16 +11:00
parent d10b3fbe00
commit 6a1233b2f6
2 changed files with 14 additions and 12 deletions

View File

@ -216,14 +216,16 @@ func parseLine(line string) (key string, value string, err error) {
value = strings.Trim(value, " ")
// check if we've got quoted values
if strings.Count(value, "\"") == 2 || strings.Count(value, "'") == 2 {
first := string(value[0:1])
last := string(value[len(value)-1:])
if first == last && strings.ContainsAny(first, `"'`) {
// pull the quotes off the edges
value = strings.Trim(value, "\"'")
value = strings.Trim(value, `"'`)
// expand quotes
value = strings.Replace(value, "\\\"", "\"", -1)
value = strings.Replace(value, `\"`, `"`, -1)
// expand newlines
value = strings.Replace(value, "\\n", "\n", -1)
value = strings.Replace(value, `\n`, "\n", -1)
}
return