Skip to content

Commit c761b26

Browse files
jub0bsseankhliao
authored andcommitted
mime: parse media types that contain braces
This CL fixes a bug introduced by CL 666655: isTokenChar would no longer (but should) report true for '{' and '}'. Fixes #76236 Change-Id: Ifc0953c30d7cae7bfba9bc4b6bb6951a83c52576 GitHub-Last-Rev: c91a75c GitHub-Pull-Request: #76243 Reviewed-on: https://go-review.googlesource.com/c/go/+/719380 Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Jorropo <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 65858a1 commit c761b26

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/mime/grammar.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ func isTokenChar(c byte) bool {
6262
1<<'^' |
6363
1<<'_' |
6464
1<<'`' |
65+
1<<'{' |
6566
1<<'|' |
67+
1<<'}' |
6668
1<<'~'
6769
return ((uint64(1)<<c)&(mask&(1<<64-1)) |
6870
(uint64(1)<<(c-64))&(mask>>64)) != 0

src/mime/mediatype_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ func init() {
413413
// Issue #48866: duplicate parameters containing equal values should be allowed
414414
{`text; charset=utf-8; charset=utf-8; format=fixed`, "text", m("charset", "utf-8", "format", "fixed")},
415415
{`text; charset=utf-8; format=flowed; charset=utf-8`, "text", m("charset", "utf-8", "format", "flowed")},
416+
417+
// Issue #76236: '{' and '}' are token chars.
418+
{"attachment; filename={file}.png", "attachment", m("filename", "{file}.png")},
416419
}
417420
}
418421

0 commit comments

Comments
 (0)