]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix application/ogg sniff signature
authorEmmanuel Odeke <emm.odeke@gmail.com>
Sun, 28 May 2017 00:25:31 +0000 (18:25 -0600)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 13 Jun 2017 20:27:43 +0000 (20:27 +0000)
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>
src/net/http/sniff.go
src/net/http/sniff_test.go

index 0d21b44a560717266ea70983ce2976c0b0fc6a44..ecc65e4de640d741388e2cb5a375b3eef76951df 100644 (file)
@@ -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{
index 38f3f8197e9a091df715e3fe59b8187938e63541..24f1298e5d9a1cf52d32c281698ee182e5eb8ad0 100644 (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 #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"},