Allow more mime types when downloading vcard

main
Bob Mottram 2024-08-14 10:10:31 +01:00
parent 533473afb8
commit 58a13af89d
1 changed files with 10 additions and 3 deletions

View File

@ -16,6 +16,7 @@ from httpcodes import http_503
from httpheaders import set_headers from httpheaders import set_headers
from utils import acct_dir from utils import acct_dir
from utils import load_json from utils import load_json
from utils import string_contains
from pgp import actor_to_vcard_xml from pgp import actor_to_vcard_xml
from pgp import actor_to_vcard from pgp import actor_to_vcard
@ -31,9 +32,15 @@ def show_vcard(self, base_dir: str, path: str, calling_domain: str,
accept_str = 'text/vcard' accept_str = 'text/vcard'
else: else:
accept_str = self.headers['Accept'] accept_str = self.headers['Accept']
print('vcard Accept: ' + accept_str) vcard_mime_types = (
if 'text/vcard' not in accept_str and \ 'text/vcard',
'application/vcard+xml' not in accept_str: 'application/vcard+xml',
'application/xml',
'application/xhtml+xml'
)
if not string_contains(accept_str, vcard_mime_types):
print('WARN: vcard is not of an expected mime type: ' +
accept_str)
return False return False
if path.startswith('/@'): if path.startswith('/@'):
if '/@/' not in path: if '/@/' not in path: