jekyll / jekyll-admin

A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites.
https://jekyll.github.io/jekyll-admin/
MIT License
2.83k stars 361 forks source link

Prevent unexpected file overwrites for collections, drafts and pages #582

Closed alzeih closed 4 years ago

alzeih commented 4 years ago

For collections, drafts and pages, return a 404 if a new or renamed item will overwrite an existing item.

Fixes #489 .

Let me know if this looks like the right approach.

Two existing tests were altered to match what I was seeing during manual testing. New tests not written yet, I'll wait until I get some feedback on the changes.

ashmaroli commented 4 years ago

@alzeih If you wish to have this shipped in the upcoming release, please find time to make the requested changes a.s.a.p. Thank you.

alzeih commented 4 years ago
  • Needs a bit of a refactoring..

Done.

  • Are resources at the /data/ namespace immune to the issue faced by other types?

No, they are not, but the front end requests for data are inconsistent with those of collections, drafts, and pages, as it doesn't send the path. I can see how to fix it, but it's a separate PR.

ashmaroli commented 4 years ago

@alzeih I'm on board with the current approach. However, I think the intent would be better expressed if the methods were named along the lines of :ensure_not_existing_file instead.

If you can add more tests, the better.