1
0
mirror of https://github.com/golang/go synced 2024-11-05 14:46:11 -07:00

net/http: fix application/ogg sniff signature

I accidentally set the wrong pattern mask as
* []byte("\x4F\x67\x67\x53\x00") --> "OggS", the byte pattern itself.
instead of
* []byte("\xFF\xFF\xFF\xFF\xFF")
which was a copy-paste error.

The correct pattern is described at
https://mimesniff.spec.whatwg.org/#matching-an-audio-or-video-type-pattern
which I was using as a reference but I mistyped.

Fixes #20513

Change-Id: Ie9cb60ac7edbf03075070878775b964116ce92d0
Reviewed-on: https://go-review.googlesource.com/44336
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Emmanuel Odeke 2017-05-27 18:25:31 -06:00 committed by Brad Fitzpatrick
parent d4ab73d1df
commit f363817f14
2 changed files with 6 additions and 2 deletions

View File

@ -107,8 +107,8 @@ var sniffSignatures = []sniffSig{
ct: "audio/basic", ct: "audio/basic",
}, },
&maskedSig{ &maskedSig{
mask: []byte("OggS\x00"), mask: []byte("\xFF\xFF\xFF\xFF\xFF"),
pat: []byte("\x4F\x67\x67\x53\x00"), pat: []byte("OggS\x00"),
ct: "application/ogg", ct: "application/ogg",
}, },
&maskedSig{ &maskedSig{

View File

@ -45,7 +45,11 @@ var sniffTests = []struct {
{"WAV audio #1", []byte("RIFFb\xb8\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"}, {"WAV audio #1", []byte("RIFFb\xb8\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"},
{"WAV audio #2", []byte("RIFF,\x00\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"}, {"WAV audio #2", []byte("RIFF,\x00\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"},
{"AIFF audio #1", []byte("FORM\x00\x00\x00\x00AIFFCOMM\x00\x00\x00\x12\x00\x01\x00\x00\x57\x55\x00\x10\x40\x0d\xf3\x34"), "audio/aiff"}, {"AIFF audio #1", []byte("FORM\x00\x00\x00\x00AIFFCOMM\x00\x00\x00\x12\x00\x01\x00\x00\x57\x55\x00\x10\x40\x0d\xf3\x34"), "audio/aiff"},
{"OGG audio", []byte("OggS\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x7e\x46\x00\x00\x00\x00\x00\x00\x1f\xf6\xb4\xfc\x01\x1e\x01\x76\x6f\x72"), "application/ogg"}, {"OGG audio", []byte("OggS\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x7e\x46\x00\x00\x00\x00\x00\x00\x1f\xf6\xb4\xfc\x01\x1e\x01\x76\x6f\x72"), "application/ogg"},
{"Must not match OGG", []byte("owow\x00"), "application/octet-stream"},
{"Must not match OGG", []byte("oooS\x00"), "application/octet-stream"},
{"Must not match OGG", []byte("oggS\x00"), "application/octet-stream"},
// Video types. // Video types.
{"MP4 video", []byte("\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00mp42isom<\x06t\xbfmdat"), "video/mp4"}, {"MP4 video", []byte("\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00mp42isom<\x06t\xbfmdat"), "video/mp4"},