From bdeab7fb83a88837e5601b6674816c6f635d1a50 Mon Sep 17 00:00:00 2001 From: freamon Date: Mon, 18 Mar 2024 21:00:17 +0000 Subject: [PATCH 1/3] Outbox / Fetched JSON fix --- app/activitypub/util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 461d8077..e70e6ff8 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -125,24 +125,24 @@ def post_to_activity(post: Post, community: Community): ], "object": { "id": create_id, - "actor": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}", + "actor": post.author.ap_public_url, "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "object": { "type": "Page", - "id": f"https://{current_app.config['SERVER_NAME']}/post/{post.id}", - "attributedTo": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}", + "id": post.ap_id, + "attributedTo": post.author.ap_public_url, "to": [ f"https://{current_app.config['SERVER_NAME']}/c/{community.name}", "https://www.w3.org/ns/activitystreams#Public" ], "name": post.title, "cc": [], - "content": post.body_html, + "content": post.body_html if post.body_html else '', "mediaType": "text/html", "source": { - "content": post.body, + "content": post.body if post.body else '', "mediaType": "text/markdown" }, "attachment": [], From 5808301770495a4a404d2065a2cec22a3914b083 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:42:53 +1300 Subject: [PATCH 2/3] remove '?asdf' stuff on the end of file names when saving --- app/activitypub/util.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 461d8077..ea3ffe0e 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -704,6 +704,9 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory): content_type_parts = content_type.split('/') if content_type_parts: file_ext = '.' + content_type_parts[-1] + else: + if '?' in file_ext: + file_ext = file_ext.split('?')[0] new_filename = gibberish(15) From 32fa6583ec90ae3804cdc3fbefab875959dc6155 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:44:47 +1300 Subject: [PATCH 3/3] ignore invalid og:image tag --- app/community/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/community/util.py b/app/community/util.py index 6fc2b438..b07e2c16 100644 --- a/app/community/util.py +++ b/app/community/util.py @@ -211,7 +211,7 @@ def save_post(form, post: Post): filename = opengraph.get('og:image') or opengraph.get('og:image:url') filename_for_extension = filename.split('?')[0] if '?' in filename else filename unused, file_extension = os.path.splitext(filename_for_extension) - if file_extension.lower() in allowed_extensions: + if file_extension.lower() in allowed_extensions and not filename.startswith('/'): file = url_to_thumbnail_file(filename) if file: file.alt_text = opengraph.get('og:title')