Skip to content

Commit 59811e5

Browse files
committed
fix display of images and only allow valid mimetypes
1 parent 629d3f6 commit 59811e5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

bash_kernel/display.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,12 @@ def display_data_for_image(filename):
103103
image = f.read()
104104
_unlink_if_temporary(filename)
105105
image_type = filetype.image_match(image).extension
106-
if image_type is None:
106+
if image_type not in ("png", "jpeg", "gif", "webp"):
107107
raise ValueError("Not a valid image: %s" % image)
108108

109-
image_data = base64.b64encode(image).decode('ascii')
110109
content = {
111110
'data': {
112-
'image/' + image_type: image_data
111+
'image/' + image_type: image
113112
},
114113
'metadata': {}
115114
}

0 commit comments

Comments
 (0)