fix: support CSV/TXT upload and add validation for Plan to Eat import (#6360)

Plan to Eat exports CSV or TXT files directly, but the importer only accepted
ZIP archives. This caused a silent failure when users uploaded CSV files.

- Extend plantoeat_recipes() to detect ZIP vs CSV/TXT by magic bytes and
  process raw CSV/TXT files directly without requiring a ZIP wrapper
- Add _validate_archive() to return a clear error report entry when the
  uploaded file is neither a ZIP nor valid UTF-8 text
- Update frontend file input to accept .zip, .csv, and .txt
- Update i18n description to mention all accepted formats
- Add plantoeat.csv test fixture and integration tests for CSV import
  and invalid file type rejection
This commit is contained in:
Hayden
2026-05-13 17:24:08 -05:00
parent af75c5f39d
commit 4039ff6655
6 changed files with 94 additions and 19 deletions

View File

@@ -337,16 +337,8 @@ const _content: Record<string, MigrationContent> = {
},
[MIGRATIONS.plantoeat]: {
text: i18n.t("migration.plantoeat.description-long"),
acceptedFileType: ".zip",
tree: [
{
icon: $globals.icons.zip,
title: "plantoeat-recipes-508318_10-13-2023.zip",
children: [
{ title: "plantoeat-recipes-508318_10-13-2023.csv", icon: $globals.icons.codeJson },
],
},
],
acceptedFileType: ".zip,.csv,.txt",
tree: false,
},
[MIGRATIONS.recipekeeper]: {
text: i18n.t("migration.recipekeeper.description-long"),