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
This commit is contained in:
Julien Cretel 2025-11-10 21:59:25 +01:00
parent a0eb4548cf
commit c91a75c2c8
No known key found for this signature in database
GPG key ID: 1449149EC303618F
2 changed files with 5 additions and 0 deletions

View file

@ -62,7 +62,9 @@ func isTokenChar(c byte) bool {
1<<'^' |
1<<'_' |
1<<'`' |
1<<'{' |
1<<'|' |
1<<'}' |
1<<'~'
return ((uint64(1)<<c)&(mask&(1<<64-1)) |
(uint64(1)<<(c-64))&(mask>>64)) != 0

View file

@ -413,6 +413,9 @@ func init() {
// Issue #48866: duplicate parameters containing equal values should be allowed
{`text; charset=utf-8; charset=utf-8; format=fixed`, "text", m("charset", "utf-8", "format", "fixed")},
{`text; charset=utf-8; format=flowed; charset=utf-8`, "text", m("charset", "utf-8", "format", "flowed")},
// Issue #76236: '{' and '}' are token chars.
{"attachment; filename={file}.png", "attachment", m("filename", "{file}.png")},
}
}