picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Pico's Markdown Filter doesn't throw errors #603

Open mayamcdougall opened 2 years ago

mayamcdougall commented 2 years ago

Mentioned in #600.

Pico's markdown filter doesn't throw any errors. This is a different behavior to Twig's built in filters, which are very verbose and will print errors directly on the page if used incorrectly.

I accidentally fed the markdown filter an array a couple times and it just silently failed. 🤦🏻‍♀️

No idea if Pico's other filters are like this or not, but it's probably worth investigating.

PhrozenByte commented 2 years ago

I just added PHP strict typing, passing an array to Pico's markdown Twig filter will now cause a fatal error. Apart from that I can't really think of additional checks. Parsedown has no error handling (even though I'm not sure whether any Markdown parser has, a Markdown parser can't know whether syntax like **foo* is meant to be *foo, or whether the author missed the second *). So, shall we leave it like this, or can you think of more reasonable checks?

mayamcdougall commented 2 years ago

Sorry, I've been meaning to get back to you on these issues. I suddenly found myself kind of busy with yet another Pico related project (besides just trying to get all the themes updated).

Yeah, I wasn't necessarily looking for Markdown errors to be noted... just the fact that it could outright fail entirely without feedback seemed unintuitive. I'm probably the only person who will ever manage to feed it the wrong data type though. 😂