Repository navigation
fix(server): hold recipe_image to the recipe-extension rule - #750
Conversation
LeMyst
left a comment
There was a problem hiding this comment.
Looks good to me. find_recipe is the only way in for GET (title and step), PUT and DELETE, so this covers the endpoint. The editor always sends .cook or .menu (edit_page redirects extensionless paths), so names with dots like Mr. Smith's Stew are unaffected. The test fails without the change and is Windows-safe.
- Nit:
recipes.rslogstracing::error!before the same 404; this path doesn't. - Possible follow-up, same kind of bug:
POST /api/shopping_listand/api/shopping_list/addonly callcheck_path, soconfig/pantry.confcan be parsed as a recipe. Only@tokens leak, so it's small.
This conflicts with #751, which also rewrites find_recipe. The resolved order would be check_path → extension check (404) → get_recipe → inside_collection.
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.
`cooklang-find` opens a name with an extension as it is, so
`/api/recipe_image/config/pantry.conf` parsed the pantry configuration
and returned its contents as step text, while PUT and DELETE wrote and
removed `pantry.{jpg,png,...}` beside it. `is_recipe_request` is the
`.cook`/`.menu` allowlist `/api/recipes/` already applies for the same
reason (#658); `find_recipe` applies it now too.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ca60bff to
d15ed18
Compare
|
Added the |
|
Thanks. The
#751's 🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst. |
Closes #697
Summary
GET/PUT/DELETE /api/recipe_image/{*path}accepted any file under the recipe directory, not just.cook/.menurecipes.find_reciperancheck_pathbut neveris_recipe_request— the extension allowlisthandlers/recipes.rshas applied since #658 for exactly this reason (cooklang-findopens a name with an extension as it is).Consequences verified live:
GET /api/recipe_image/config/pantry.conf→ 200 with the pantry's contents returned as step text.PUTwroteconfig/notes.jpg-style files beside any file;DELETEremoved{stem}.{jpg,jpeg,png,webp}beside any file.Changes
find_recipenow refuses a non-.cook/.menupath with the same 404/api/recipes/returns — which covers GET, PUT and DELETE since all three resolve the recipe through it.Test plan
a_non_recipe_file_is_not_a_recipeintests/recipe_image_api_test.rs:config/pantry.confandnotes.txtget 404 on all three verbs and nothing is written or removed.Generated with Devin