Private
Public Access
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:
1 parent
753ae9efc7
commit
f818b11041
6 files changed
+86
-4
No files matched your search
+3
-2
@@ -11,7 +11,7 @@ from apps.articles.models import SubscriptionTag, Tag
|
||||
|
||||
from .forms import AddFeedForm, EditSubscriptionForm, OPMLImportForm
|
||||
from .models import Feed, Subscription
|
||||
from .opml import export_opml, import_opml, parse_opml
|
||||
from .opml import export_opml, extract_opml_bytes, import_opml, parse_opml
|
||||
from .services.fetcher import fetch_and_ingest
|
||||
from .tasks import import_opml_task
|
||||
|
||||
@@ -148,8 +148,9 @@ def unsubscribe(request, subscription_id):
|
||||
def import_opml_view(request):
|
||||
form = OPMLImportForm(request.POST or None, request.FILES or None)
|
||||
if request.method == "POST" and form.is_valid():
|
||||
content = form.cleaned_data["opml_file"].read()
|
||||
uploaded = form.cleaned_data["opml_file"].read()
|
||||
try:
|
||||
content = extract_opml_bytes(uploaded)
|
||||
entry_count = len(parse_opml(BytesIO(content)))
|
||||
except Exception:
|
||||
messages.error(request, "That file doesn't look like a valid OPML export.")
|
||||
|
||||
Reference in new issue
Block a user