]> Cypherpunks repositories - gostls13.git/commit
mime: correctly detect non-ASCII characters in FormatMediaType
authorDavid Heuschmann <heuschmann.d@gmail.com>
Tue, 20 Nov 2018 10:11:59 +0000 (11:11 +0100)
committerIan Lance Taylor <iant@golang.org>
Tue, 20 Nov 2018 14:39:44 +0000 (14:39 +0000)
commit2cc6d62d666f49d91c6d088bcba3ef18072d093f
tree61e61418e587b044991a8965c99231a57101c6d2
parent399fec28e22ac01b7a4fe56028c3016a0df6d2e6
mime: correctly detect non-ASCII characters in FormatMediaType

FormatMediaType used rune&0x80==0 to check if parameter values consisted
of valid ascii charaters. Comparing strings using their runes instead of
their bytes leads to some non-ascii strings to pass as valid.

E.g. the rune for 'Ą' is 0x104, 0x104 & 0x80 => 0. Its byte
representation is 0xc4 0x84, both of which result in non zero values
when masked with 0x80

Fixes #28849

Change-Id: Ib9fb4968bcbbec0197d81136f380d40a2a56c14b
Reviewed-on: https://go-review.googlesource.com/c/150417
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/mime/mediatype.go
src/mime/mediatype_test.go