-
Notifications
You must be signed in to change notification settings - Fork 48
Activity
Hi iantonge,
I just tested this to see what happens in my local app with a strict CSP set. When using the swap='morph:xxxxx' swap format it does indeed throw unsafe eval CSP warnings. But if your application only uses the safe non eval versions then you should not get any CSP violation warnings which I think this is really equivalent to the safe.js version you were thinking about anyway. htmx has a nicer option to disables its use of eval so you never get the warnings and the eval functions just fail silently but I think getting the warnings while your developing and testing your app is quite a good thing as long as you know to check your console for issues.
Also a note that most of the advanced idiomorph behavior options that you can set via the eval can also be set via javascript updating Idiomorph.defaults object to override the defaults.
Thanks for taking the time to look at this. My experience was that I got a CSP violation and the js fell over even though that line was never hit - although testing it in a fresh project now I can see that is not the case. I can only assume I had a typo which meant that actually that line was hit. I think we can chalk this up to "Problem exists between keyboard and chair".
I'm working on a site with a strict CSP (
default-src 'self';script-src 'self'). Both HTMX and idiomorph work just fine with the strict CSP, however the HTMX extension includes the following:idiomorph/src/idiomorph-htmx.js
Line 8 in 917587a
This requires adding
unsafe-evalto my CSP, which is not something I'm prepared to do. Fortunately I don't need thehx-swap='morph:<expr>'feature, so I was able to work around this by basically copy/pasting the current file and removing this block of code - which is fine, but now I need to make sure I keep an eye on this file and incorporate any meaningful changes whenever I upgrade the library, which is not optimal. It certainly created some friction for me when trying to get idiomorph up and running.I understand removing a feature probably isn't a viable option, but perhaps there could be a separate
idiomorph-htmx-safe.jsfile? If nothing else it might be worth flagging up theunsafe-inlinerequirement in the documentation.Alternatively, "that's just how it is, deal with it" is a perfectly reasonable response :-)