Skip to content

Commit

Permalink
net/http: fix application/ogg sniff signature
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
odeke-em authored and bradfitz committed Jun 13, 2017
1 parent d4ab73d commit f363817
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net/http/sniff.go
Expand Up @@ -107,8 +107,8 @@ var sniffSignatures = []sniffSig{
ct: "audio/basic",
},
&maskedSig{
mask: []byte("OggS\x00"),
pat: []byte("\x4F\x67\x67\x53\x00"),
mask: []byte("\xFF\xFF\xFF\xFF\xFF"),
pat: []byte("OggS\x00"),
ct: "application/ogg",
},
&maskedSig{
Expand Down
4 changes: 4 additions & 0 deletions src/net/http/sniff_test.go
Expand Up @@ -45,7 +45,11 @@ var sniffTests = []struct {
{"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"},
{"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"},
{"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.
{"MP4 video", []byte("\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00mp42isom<\x06t\xbfmdat"), "video/mp4"},
Expand Down

0 comments on commit f363817

Please sign in to comment.