component AP gateway: don't percent-encode @:

Mastodon doesn't like when "@" is percent-encoded (because it doesn't do it, and it checks
that the URL matches the ID without taking care of percent-encoding).
This commit is contained in:
Goffi 2023-02-10 17:20:02 +01:00
commit 52f7a2b11f
2 changed files with 21 additions and 18 deletions

View file

@ -838,7 +838,7 @@ class APGateway:
"""
return parse.urljoin(
self.base_ap_url,
str(Path(type_).joinpath(*(parse.quote_plus(a) for a in args)))
str(Path(type_).joinpath(*(parse.quote_plus(a, safe="@") for a in args)))
)
def isLocalURL(self, url: str) -> bool:

View file

@ -592,7 +592,9 @@ class HTTPAPGServer(web_resource.Resource):
"https://w3id.org/security/v1"
],
"id": ap_url,
# XXX: Mastodon doesn't like percent-encode arobas, so we have to unescape it
# if it is escaped
"id": ap_url.replace("%40", "@"),
"type": "Person",
"preferredUsername": preferred_username,
"inbox": inbox,
@ -637,7 +639,8 @@ class HTTPAPGServer(web_resource.Resource):
return parse.urljoin(
f"https://{self.apg.public_url}",
request.path.decode().rstrip("/")
)
# we unescape "@" for the same reason as in [APActorRequest]
).replace("%40", "@")
def queryData2RSMRequest(
self,