Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
b990c40d
Commit
b990c40d
authored
Aug 09, 2013
by
Pieter Droogendijk
Committed by
Brad Fitzpatrick
Aug 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mime: escape backslash in attribute values
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/12689045
parent
2db5e4bb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
mediatype.go
src/pkg/mime/mediatype.go
+1
-1
mediatype_test.go
src/pkg/mime/mediatype_test.go
+9
-0
No files found.
src/pkg/mime/mediatype.go
View file @
b990c40d
...
...
@@ -47,7 +47,7 @@ func FormatMediaType(t string, param map[string]string) string {
b
.
WriteByte
(
'"'
)
offset
:=
0
for
index
,
character
:=
range
value
{
if
character
==
'"'
||
character
==
'\
r
'
{
if
character
==
'"'
||
character
==
'\
\
'
{
b
.
WriteString
(
value
[
offset
:
index
])
offset
=
index
b
.
WriteByte
(
'\\'
)
...
...
src/pkg/mime/mediatype_test.go
View file @
b990c40d
...
...
@@ -282,8 +282,17 @@ type formatTest struct {
var
formatTests
=
[]
formatTest
{
{
"noslash"
,
nil
,
""
},
{
"foo bar/baz"
,
nil
,
""
},
{
"foo/bar baz"
,
nil
,
""
},
{
"foo/BAR"
,
nil
,
"foo/bar"
},
{
"foo/BAR"
,
map
[
string
]
string
{
"X"
:
"Y"
},
"foo/bar; x=Y"
},
{
"foo/BAR"
,
map
[
string
]
string
{
"space"
:
"With space"
},
`foo/bar; space="With space"`
},
{
"foo/BAR"
,
map
[
string
]
string
{
"quote"
:
`With "quote`
},
`foo/bar; quote="With \"quote"`
},
{
"foo/BAR"
,
map
[
string
]
string
{
"bslash"
:
`With \backslash`
},
`foo/bar; bslash="With \\backslash"`
},
{
"foo/BAR"
,
map
[
string
]
string
{
"both"
:
`With \backslash and "quote`
},
`foo/bar; both="With \\backslash and \"quote"`
},
{
"foo/BAR"
,
map
[
string
]
string
{
""
:
"empty attribute"
},
""
},
{
"foo/BAR"
,
map
[
string
]
string
{
"bad attribute"
:
"baz"
},
""
},
{
"foo/BAR"
,
map
[
string
]
string
{
"nonascii"
:
"not an ascii character: ä"
},
""
},
}
func
TestFormatMediaType
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment