FIX: Issues with custom icons in themes (PR #13732)

Fixes two issues:

  • ignores invalid XML in custom icon sprite SVG file
  • clears SVG sprite cache when deleting an icons-sprite upload in a theme

GitHub

A couple of points here:

  1. I think the log message here is a little too generic and doesn’t tell what the problem is exactly. Can we include the type/class and message (if any) of the rescued error in the log message here?

  2. I wonder if we should also validate the XML/sprite file and surface errors earlier when it’s uploaded? I think right now (correct me if I’m wrong) the app doesn’t perform any checks on sprite files bundled with themes, and so when someone uploads a broken sprite file, Discourse accepts it but it won’t have any effects because it’s broken and they’d have to remember to check /logs to figure out what’s wrong. Obviously this needs a fair amount of work, so feel free to merge this PR now and we can improve this later.

Thanks @OsamaSayegh, I have made both adjustments. In the UI, admins that upload a broken sprite will see this:

Perfect, thanks you so much!