fix: save avatars from own GoToSocial and Bluesky PDSes (v2.13.1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f3ed1b3488
commit
65fc246d55
7 files changed
+145
-11
No files matched your search
@@ -562,3 +562,25 @@ def test_threads_avatar_kept_while_its_copy_exists(app, client, web):
|
||||
client.harvest = Harvest([again])
|
||||
run(app)
|
||||
assert rows(app, note.id)[0]["author_photo"] == "https://cdn.example/p.jpg?sig=1"
|
||||
|
||||
|
||||
def test_avatars_from_own_gotosocial_and_bluesky_pds(app, web, monkeypatch):
|
||||
"""v2.13.1: own GoToSocial may resolve to a private address; Bluesky CDN avatars come from the PDS"""
|
||||
did, cid = "did:plc:abc123", "bafkreiabc"
|
||||
web.files[f"{GTS}/fileserver/a/avatar.png"] = png()
|
||||
web.files[f"https://plc.directory/{did}"] = json.dumps(
|
||||
{"service": [{"id": "#atproto_pds", "serviceEndpoint": "https://pds.example"}]}).encode()
|
||||
web.files[f"https://pds.example/xrpc/com.atproto.sync.getBlob?did={did}&cid={cid}"] = png("blue")
|
||||
real_resolve = resolve
|
||||
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo",
|
||||
lambda host, *a, **k: [(2, 1, 6, "", ("172.20.0.5", 0))]
|
||||
if host == "social.example" else real_resolve(host))
|
||||
data = app.config["DATA_PATH"]
|
||||
with app.app_context():
|
||||
assert avatars.fetch(data, f"{GTS}/fileserver/a/avatar.png", SITE)
|
||||
assert avatars.fetch(data, f"https://cdn.bsky.app/img/avatar/plain/{did}/{cid}@jpeg", SITE)
|
||||
# Other private addresses stay blocked
|
||||
web.files["https://internal.example/a.png"] = png()
|
||||
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo",
|
||||
lambda host, *a, **k: [(2, 1, 6, "", ("10.0.0.5", 0))])
|
||||
assert not avatars.fetch(data, "https://internal.example/a.png", SITE)
|
||||
Reference in new issue
Block a user