Use urljoin
to safely join activitypub URL
This commit is contained in:
parent
23ce49ca8f
commit
1934b36ec1
1 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
|
@ -56,10 +57,13 @@ def activitypub_proxy(request: HttpRequest) -> HttpResponse:
|
||||||
if not settings.ACTIVITYPUB_HOST:
|
if not settings.ACTIVITYPUB_HOST:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
try:
|
activitypub_url = urljoin(
|
||||||
return proxy_view(
|
"https://" + settings.ACTIVITYPUB_HOST,
|
||||||
request,
|
request.path,
|
||||||
f"https://{settings.ACTIVITYPUB_HOST}{request.path}",
|
allow_fragments=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return proxy_view(request, activitypub_url)
|
||||||
except RequestException:
|
except RequestException:
|
||||||
return HttpResponse(status_code=502)
|
return HttpResponse(status_code=502)
|
||||||
|
|
Loading…
Reference in a new issue