Sanitize recipe backup filenames (#287)

Fixes #275
This commit is contained in:
sephrat 2021-04-11 23:16:51 +02:00 committed by GitHub
parent 406dae6e97
commit e8c121de04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2139 additions and 2113 deletions

View File

@ -4,11 +4,12 @@ from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import Union from typing import Union
from mealie.core import root_logger
from jinja2 import Template from jinja2 import Template
from mealie.core import root_logger
from mealie.core.config import app_dirs from mealie.core.config import app_dirs
from mealie.db.database import db from mealie.db.database import db
from mealie.db.db_setup import create_session from mealie.db.db_setup import create_session
from pathvalidate import sanitize_filename
from pydantic.main import BaseModel from pydantic.main import BaseModel
logger = root_logger.get_logger() logger = root_logger.get_logger()
@ -78,7 +79,8 @@ class ExportDatabase:
ExportDatabase._write_json_file(items, out_dir.joinpath(f"{folder_name}.json")) ExportDatabase._write_json_file(items, out_dir.joinpath(f"{folder_name}.json"))
else: else:
for item in items: for item in items:
ExportDatabase._write_json_file(item, out_dir.joinpath(f"{item.get('name')}.json")) filename = sanitize_filename(f"{item.get('name')}.json")
ExportDatabase._write_json_file(item, out_dir.joinpath(filename))
@staticmethod @staticmethod
def _write_json_file(data: Union[dict, list], out_file: Path): def _write_json_file(data: Union[dict, list], out_file: Path):

4121
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,64 @@
[tool.poetry] [tool.poetry]
name = "mealie" name = "mealie"
version = "0.3.0" version = "0.3.0"
description = "A Recipe Manager" description = "A Recipe Manager"
authors = ["Hayden <hay-kot@pm.me>"] authors = ["Hayden <hay-kot@pm.me>"]
license = "MIT" license = "MIT"
[tool.poetry.scripts] [tool.poetry.scripts]
start = "mealie.app:main" start = "mealie.app:main"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = "^3.9"
aiofiles = "0.5.0" aiofiles = "0.5.0"
aniso8601 = "7.0.0" aniso8601 = "7.0.0"
appdirs = "1.4.4" appdirs = "1.4.4"
fastapi = "^0.63.0" fastapi = "^0.63.0"
uvicorn = {extras = ["standard"], version = "^0.13.0"} uvicorn = {extras = ["standard"], version = "^0.13.0"}
APScheduler = "^3.6.3" APScheduler = "^3.6.3"
SQLAlchemy = "^1.3.22" SQLAlchemy = "^1.3.22"
Jinja2 = "^2.11.2" Jinja2 = "^2.11.2"
python-dotenv = "^0.15.0" python-dotenv = "^0.15.0"
python-slugify = "^4.0.1" python-slugify = "^4.0.1"
requests = "^2.25.1" requests = "^2.25.1"
PyYAML = "^5.3.1" PyYAML = "^5.3.1"
extruct = "^0.12.0" extruct = "^0.12.0"
scrape-schema-recipe = "^0.1.3" scrape-schema-recipe = "^0.1.3"
python-multipart = "^0.0.5" python-multipart = "^0.0.5"
fastapi-camelcase = "^1.0.2" fastapi-camelcase = "^1.0.2"
bcrypt = "^3.2.0" bcrypt = "^3.2.0"
python-jose = "^3.2.0" python-jose = "^3.2.0"
passlib = "^1.7.4" passlib = "^1.7.4"
lxml = "4.6.2" lxml = "4.6.2"
Pillow = "^8.2.0" Pillow = "^8.2.0"
pathvalidate = "^2.4.1"
[tool.poetry.dev-dependencies]
pylint = "^2.6.0" [tool.poetry.dev-dependencies]
black = "^20.8b1" pylint = "^2.6.0"
pytest = "^6.2.1" black = "^20.8b1"
pytest-cov = "^2.11.0" pytest = "^6.2.1"
mkdocs-material = "^7.0.2" pytest-cov = "^2.11.0"
flake8 = "^3.9.0" mkdocs-material = "^7.0.2"
coverage = "^5.5" flake8 = "^3.9.0"
coverage = "^5.5"
[build-system]
requires = ["poetry-core>=1.0.0"] [build-system]
build-backend = "poetry.core.masonry.api" requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.black]
line-length = 120 [tool.black]
line-length = 120
[tool.pytest.ini_options]
minversion = "6.0" [tool.pytest.ini_options]
addopts = "-ra -q --cov=mealie" minversion = "6.0"
python_files = 'test_*' addopts = "-ra -q --cov=mealie"
python_classes = '*Tests' python_files = 'test_*'
python_functions = 'test_*' python_classes = '*Tests'
testpaths = [ python_functions = 'test_*'
"tests", testpaths = [
] "tests",
]
[tool.coverage.report]
[tool.coverage.report]
skip_empty = true skip_empty = true