]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.25] mime: parse media types that contain braces
authorJulien Cretel <jub0bsinthecloud@gmail.com>
Mon, 10 Nov 2025 21:20:09 +0000 (21:20 +0000)
committerCherry Mui <cherryyz@google.com>
Tue, 25 Nov 2025 16:32:36 +0000 (08:32 -0800)
This CL fixes a bug introduced by CL 666655: isTokenChar would no longer
(but should) report true for '{' and '}'.

Fixes #76245

Change-Id: Ifc0953c30d7cae7bfba9bc4b6bb6951a83c52576
GitHub-Last-Rev: c91a75c2c8778a9a8343c6bb4fa89eb1f978059f
GitHub-Pull-Request: golang/go#76243
Reviewed-on: https://go-review.googlesource.com/c/go/+/719380
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit c761b26b56eec36390885e5373aab2fd17dc67ef)
Reviewed-on: https://go-review.googlesource.com/c/go/+/721000
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/mime/grammar.go
src/mime/mediatype_test.go

index cc578fbcfd4168124bdc6415b872d83e9bc541dd..1efd8a16dec607de16233b9279e4b45ff2f1a964 100644 (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
index 251df8d6691ab9abc0112b9c994e07fb739d63d4..da8d64de7a3f0cbc7c855fd002fbb65e8a5a9d15 100644 (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")},
        }
 }