@@ -451,7 +451,12 @@ def _is_displayable(self, mime_type: str | None) -> bool:
451451 """
452452 if isinstance (mime_type , str ):
453453 mime_type , _ , _ = mime_type .partition (";" )
454- return mime_type in load_configuration ().displayable_content_types
454+ return mime_type in {
455+ "text/gemini" ,
456+ "text/plain" ,
457+ "text/gopher-menu" ,
458+ * load_configuration ().displayable_content_types ,
459+ }
455460
456461 async def _handle_input_request (
457462 self , location : GeminiURI , prompt : str , sensitive : bool
@@ -696,6 +701,11 @@ async def _load_from_gopher(self, request: OpenLocation) -> None:
696701 uri = request .location
697702 assert isinstance (uri , GopherURI )
698703
704+ mime_type = ItemType (uri .item_type ).mime_type
705+ if not self ._is_displayable (mime_type ):
706+ self .post_message (OpenUnsupportedMIMEType (uri , mime_type ))
707+ return
708+
699709 try :
700710 self ._command_line .working = True
701711 self .post_message (
@@ -704,7 +714,7 @@ async def _load_from_gopher(self, request: OpenLocation) -> None:
704714 location = uri ,
705715 original_location = uri ,
706716 content = (await GopherClient ().request (uri )).text ,
707- mime_type = ItemType ( uri . item_type ). mime_type ,
717+ mime_type = mime_type ,
708718 ),
709719 original_request = request ,
710720 )
@@ -881,8 +891,8 @@ async def _open_unsupported_mime_type(
881891 message: The message containing the unsupported MIME type.
882892 """
883893
884- # There's no reason why we should be here for Finger or Gopher URIs.
885- if isinstance (message .location , ( FingerURI , GopherURI ) ):
894+ # There's no reason why we should be here for Finger URIs.
895+ if isinstance (message .location , FingerURI ):
886896 self .notify (
887897 f"Unexpected request to open { message .location } : please let Dave know" ,
888898 severity = "warning" ,
@@ -911,7 +921,7 @@ async def _open_unsupported_mime_type(
911921 if open_uri :
912922 open_in_browser (
913923 str (message .location )
914- if isinstance (message .location , GeminiURI )
924+ if isinstance (message .location , ( GeminiURI , GopherURI ) )
915925 else message .location .resolve ().as_uri ()
916926 )
917927
0 commit comments