diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-09 14:45:32 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-09 14:45:32 +0100 |
| commit | 32f3d9fae7ad0a4ad7cc9c74d81a6fd670912fbe (patch) | |
| tree | 42e0fd73b717c05c4ef69e6a64013fdde2fbfe88 /mammoth/images.py | |
| parent | 1cac2458ea3c0a68754f1cc86df3aee50b02782b (diff) | |
Check image content type for backslashes
Diffstat (limited to 'mammoth/images.py')
| -rw-r--r-- | mammoth/images.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mammoth/images.py b/mammoth/images.py index 21b9288..1623a73 100644 --- a/mammoth/images.py +++ b/mammoth/images.py @@ -1,4 +1,5 @@ import base64 +import re from . import html @@ -26,3 +27,11 @@ def data_uri(image): return { "src": "data:{0};base64,{1}".format(image.content_type, encoded_src) } + + +def image_filename_extension(image): + result = re.split(r"/|\\", image.content_type) + if len(result) < 2: + return None + else: + return result[1] |
