So... CSP is implemented successfully on my site. However - my website use many inline scripts to redirect visitors depending on their HTML checkbox selections. In development, unsafe-inline has sufficed, but I'm now ready to go live and this is a big roadblock preventing me from doing so.
<label for="giorgio-armani" class="d-flex">
<input type="checkbox" id="giorgio-armani" class="mr-2 mt-1" onChange="window.location.href='/shop/brands/giorgio-armani'"> Giorgio Armani</label>
This would be an example of my code. As it's for a site menu, there can be literally hundreds of the same checkboxes in a row to different destinations.
I did have a solution link bookmarked to allow me to return to this at a later date, but I appear to have deleted it...
All help appreciated!
One approach is to remove the need for the inline event bindings and make them dynamically with your scripts. Such as...
So lets look at this.
gotoclass on it, signifying that this is an element that we have generalized to behave in the manner that we want. In this case, it needs to change what page we are on.data-targetattribute on it. We use this as a data model attribute to hold data related to the "link" that we need in order to perform our page changing logic.gotoclass on it. If it does, we do our work.