~singpolyma/cheogram

a445129a5e2da3690cfaaa90e6bded8e1a49d1b6 — Stephen Paul Weber a month ago 4f6e7bb
Blacklist uncommon file extensions

Some MIME types are a bit ambiguous.  Do not use uncommon variants of the file
extension, which our nginx and our clients are unlikely to support.
1 files changed, 13 insertions(+), 2 deletions(-)

M Main.hs
M Main.hs => Main.hs +13 -2
@@ 57,9 57,20 @@ import StanzaRec
instance Ord JID where
	compare x y = compare (show x) (show y)

-- Do not use uncommon file extensions for ambiguous MIME types
badExts :: [Text]
badExts = [
		s"mpg4", s"mp4v",
		s"mpga", s"m2a", s"m3a", s"mp2", s"mp2a",
		s"m1v", s"m2v", s"mpe"
	]

mimeToExtMap :: SMap.Map String Text
mimeToExtMap = SMap.fromList $ map (\(ext, mimeBytes) ->
		(textToString (decodeUtf8 mimeBytes), ext)
mimeToExtMap = SMap.fromList $ mapMaybe (\(ext, mimeBytes) ->
		if ext `elem` badExts then
			Nothing
		else
			Just (textToString (decodeUtf8 mimeBytes), ext)
	) $ SMap.toList defaultMimeMap

queryDisco to from = (:[]) . mkStanzaRec <$> queryDiscoWithNode Nothing to from