Skip to content

Commit

Permalink
guard for index out of bounds in rfc2047AttributeName (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
requaos authored and jhillyerd committed Jan 25, 2019
1 parent 4ec8ed2 commit 32384ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,10 @@ func rfc2047AttributeName(s string) string {
// then the attribute value should be quoted
keyValuePair := strings.SplitAfter(decodeHeader(pair[0]), "=")
// only quote the parameter value if it isn't already quoted
if !strings.HasPrefix(keyValuePair[1], "\"") {
keyValuePair[1] = fmt.Sprintf("\"%s", keyValuePair[1])
if len(keyValuePair) > 1 {
if !strings.HasPrefix(keyValuePair[1], "\"") {
keyValuePair[1] = fmt.Sprintf("\"%s", keyValuePair[1])
}
}
pair[0] = strings.Join(keyValuePair, "")
return strings.Join(pair, "")
Expand Down

0 comments on commit 32384ef

Please sign in to comment.