diff --git a/client/html/post_merge_side.tpl b/client/html/post_merge_side.tpl index 53dd31f..a4e77ed 100644 --- a/client/html/post_merge_side.tpl +++ b/client/html/post_merge_side.tpl @@ -36,6 +36,7 @@ 'image/jpeg': 'JPEG', 'image/png': 'PNG', 'image/webp': 'WEBP', + 'image/bmp': 'BMP', 'video/webm': 'WEBM', 'video/mp4': 'MPEG-4', 'application/x-shockwave-flash': 'SWF', diff --git a/client/html/post_readonly_sidebar.tpl b/client/html/post_readonly_sidebar.tpl index cfbfd10..a54e7bb 100644 --- a/client/html/post_readonly_sidebar.tpl +++ b/client/html/post_readonly_sidebar.tpl @@ -9,6 +9,7 @@ 'image/jpeg': 'JPEG', 'image/png': 'PNG', 'image/webp': 'WEBP', + 'image/bmp': 'BMP', 'video/webm': 'WEBM', 'video/mp4': 'MPEG-4', 'application/x-shockwave-flash': 'SWF', diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index 7daf4fb..f1eb47c 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -15,6 +15,7 @@ function _mimeTypeToPostType(mimeType) { "image/jpeg": "image", "image/png": "image", "image/webp": "image", + "image/bmp": "image", "video/mp4": "video", "video/webm": "video", }[mimeType] || "unknown" @@ -109,6 +110,7 @@ class Url extends Uploadable { png: "image/png", gif: "image/gif", webp: "image/webp", + bmp: "image/bmp", mp4: "video/mp4", webm: "video/webm", }; diff --git a/server/szurubooru/func/mime.py b/server/szurubooru/func/mime.py index bd553fc..e521c25 100644 --- a/server/szurubooru/func/mime.py +++ b/server/szurubooru/func/mime.py @@ -21,6 +21,9 @@ def get_mime_type(content: bytes) -> str: if content[8:12] == b"WEBP": return "image/webp" + if content[0:2] == b"BM": + return "image/bmp" + if content[0:4] == b"\x1A\x45\xDF\xA3": return "video/webm" @@ -37,6 +40,7 @@ def get_extension(mime_type: str) -> Optional[str]: "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", + "image/bmp": "bmp", "video/mp4": "mp4", "video/webm": "webm", "application/octet-stream": "dat", @@ -58,6 +62,7 @@ def is_image(mime_type: str) -> bool: "image/png", "image/gif", "image/webp", + "image/bmp", ) diff --git a/server/szurubooru/tests/assets/bmp.bmp b/server/szurubooru/tests/assets/bmp.bmp new file mode 100644 index 0000000..3a18269 Binary files /dev/null and b/server/szurubooru/tests/assets/bmp.bmp differ diff --git a/server/szurubooru/tests/func/test_mime.py b/server/szurubooru/tests/func/test_mime.py index 0d8f645..62fd4a7 100644 --- a/server/szurubooru/tests/func/test_mime.py +++ b/server/szurubooru/tests/func/test_mime.py @@ -13,6 +13,7 @@ from szurubooru.func import mime ("jpeg.jpg", "image/jpeg"), ("gif.gif", "image/gif"), ("webp.webp", "image/webp"), + ("bmp.bmp", "image/bmp"), ("text.txt", "application/octet-stream"), ], ) @@ -34,6 +35,7 @@ def test_get_mime_type_for_empty_file(): ("image/jpeg", "jpg"), ("image/gif", "gif"), ("image/webp", "webp"), + ("image/bmp", "bmp"), ("application/octet-stream", "dat"), ], ) @@ -75,9 +77,11 @@ def test_is_video(input_mime_type, expected_state): ("image/gif", True), ("image/png", True), ("image/jpeg", True), + ("image/bmp", True), ("IMAGE/GIF", True), ("IMAGE/PNG", True), ("IMAGE/JPEG", True), + ("IMAGE/BMP", True), ("image/anything_else", False), ("not an image", False), ], diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py index 6139555..0693741 100644 --- a/server/szurubooru/tests/func/test_posts.py +++ b/server/szurubooru/tests/func/test_posts.py @@ -392,6 +392,13 @@ def test_update_post_source_with_too_long_string(): model.Post.TYPE_IMAGE, "1_244c8840887984c4.gif", ), + ( + False, + "bmp.bmp", + "image/bmp", + model.Post.TYPE_IMAGE, + "1_244c8840887984c4.bmp", + ), ( False, "gif-animated.gif",