mirror of
https://github.com/golang/go
synced 2024-11-22 03:24:41 -07:00
mime: fix build
The fix is to add ' ' after ';' so that we match what we used to generate. Packages like http look for the string with the space in it, and I don't see a reason to be so terse. Also s/buffer/b/ TBR=bradfitz CC=golang-dev https://golang.org/cl/4959044
This commit is contained in:
parent
75199664d9
commit
91643acc6f
@ -21,39 +21,40 @@ func FormatMediaType(t, sub string, param map[string]string) string {
|
||||
if !(IsToken(t) && IsToken(sub)) {
|
||||
return ""
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(strings.ToLower(t))
|
||||
buffer.WriteByte('/')
|
||||
buffer.WriteString(strings.ToLower(sub))
|
||||
var b bytes.Buffer
|
||||
b.WriteString(strings.ToLower(t))
|
||||
b.WriteByte('/')
|
||||
b.WriteString(strings.ToLower(sub))
|
||||
|
||||
for attribute, value := range param {
|
||||
buffer.WriteByte(';')
|
||||
b.WriteByte(';')
|
||||
b.WriteByte(' ')
|
||||
if !IsToken(attribute) {
|
||||
return ""
|
||||
}
|
||||
buffer.WriteString(strings.ToLower(attribute))
|
||||
buffer.WriteByte('=')
|
||||
b.WriteString(strings.ToLower(attribute))
|
||||
b.WriteByte('=')
|
||||
if IsToken(value) {
|
||||
buffer.WriteString(value)
|
||||
b.WriteString(value)
|
||||
continue
|
||||
}
|
||||
|
||||
buffer.WriteByte('"')
|
||||
b.WriteByte('"')
|
||||
offset := 0
|
||||
for index, character := range value {
|
||||
if character == '"' || character == '\r' {
|
||||
buffer.WriteString(value[offset:index])
|
||||
b.WriteString(value[offset:index])
|
||||
offset = index
|
||||
buffer.WriteByte('\\')
|
||||
b.WriteByte('\\')
|
||||
}
|
||||
if character&0x80 != 0 {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
buffer.WriteString(value[offset:])
|
||||
buffer.WriteByte('"')
|
||||
b.WriteString(value[offset:])
|
||||
b.WriteByte('"')
|
||||
}
|
||||
return buffer.String()
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func checkMediaTypeDisposition(s string) os.Error {
|
||||
|
Loading…
Reference in New Issue
Block a user