mirror of
https://github.com/golang/go
synced 2024-11-22 09:14:40 -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)) {
|
if !(IsToken(t) && IsToken(sub)) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var buffer bytes.Buffer
|
var b bytes.Buffer
|
||||||
buffer.WriteString(strings.ToLower(t))
|
b.WriteString(strings.ToLower(t))
|
||||||
buffer.WriteByte('/')
|
b.WriteByte('/')
|
||||||
buffer.WriteString(strings.ToLower(sub))
|
b.WriteString(strings.ToLower(sub))
|
||||||
|
|
||||||
for attribute, value := range param {
|
for attribute, value := range param {
|
||||||
buffer.WriteByte(';')
|
b.WriteByte(';')
|
||||||
|
b.WriteByte(' ')
|
||||||
if !IsToken(attribute) {
|
if !IsToken(attribute) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
buffer.WriteString(strings.ToLower(attribute))
|
b.WriteString(strings.ToLower(attribute))
|
||||||
buffer.WriteByte('=')
|
b.WriteByte('=')
|
||||||
if IsToken(value) {
|
if IsToken(value) {
|
||||||
buffer.WriteString(value)
|
b.WriteString(value)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.WriteByte('"')
|
b.WriteByte('"')
|
||||||
offset := 0
|
offset := 0
|
||||||
for index, character := range value {
|
for index, character := range value {
|
||||||
if character == '"' || character == '\r' {
|
if character == '"' || character == '\r' {
|
||||||
buffer.WriteString(value[offset:index])
|
b.WriteString(value[offset:index])
|
||||||
offset = index
|
offset = index
|
||||||
buffer.WriteByte('\\')
|
b.WriteByte('\\')
|
||||||
}
|
}
|
||||||
if character&0x80 != 0 {
|
if character&0x80 != 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer.WriteString(value[offset:])
|
b.WriteString(value[offset:])
|
||||||
buffer.WriteByte('"')
|
b.WriteByte('"')
|
||||||
}
|
}
|
||||||
return buffer.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMediaTypeDisposition(s string) os.Error {
|
func checkMediaTypeDisposition(s string) os.Error {
|
||||||
|
Loading…
Reference in New Issue
Block a user