Accept a FreshRSS "Export" .zip directly for OPML import

FreshRSS's Export feature produces a .zip (an .opml.xml plus a starred-
articles .json this app doesn't import) rather than a bare .opml file —
uploading that zip as-is failed with "That file doesn't look like a valid
OPML export" since defusedxml can't parse a zip as XML.

apps.feeds.opml.extract_opml_bytes detects a zip upload and pulls the
.opml/.opml.xml member out of it before parsing; a bare .opml upload is
returned unchanged, so existing behavior is untouched. Verified against
the reporter's actual FreshRSS export (18 feeds across 6 categories) both
directly through extract_opml_bytes/parse_opml and as a real upload
through the running app.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 21:45:16 -06:00
1 parent 753ae9efc7
commit f818b11041
6 files changed
+86 -4

No files matched your search

+21
View File
@@ -135,6 +135,27 @@ def test_import_opml_view_creates_subscriptions(client, alice):
assert Subscription.objects.filter(user=alice).count() == 2
@pytest.mark.django_db
def test_import_opml_view_accepts_a_freshrss_export_zip(client, alice):
import zipfile
from io import BytesIO
client.login(username="alice", password="pw-alice-123")
buf = BytesIO()
with zipfile.ZipFile(buf, "w") as archive:
archive.writestr("feeds_2026-10-30.opml.xml", SIMPLE_OPML)
archive.writestr("starred_2026-10-30.json", b'{"items": []}')
upload = SimpleUploadedFile(
"freshrss_export.zip", buf.getvalue(), content_type="application/zip"
)
response = client.post(reverse("feeds:import_opml"), {"opml_file": upload})
assert response.status_code == 302
assert Subscription.objects.filter(user=alice).count() == 2
@pytest.mark.django_db
def test_import_opml_view_rejects_malformed_file(client, alice):
client.login(username="alice", password="pw-alice-123")