Back to DevLog

Security Hardening & Template Generation: A Tale of SVGs and WordPress Kses

3 min read

Had one of those sessions where security fixes lead you down a rabbit hole, but in a good way.

Started the day tackling some security issues in our honeybun theme. Found unescaped PHP echo statements in page-home.php and page-industries.php that needed fixing. The tricky part? We're dealing with SVG output, so I couldn't just slap esc_html() on everything and call it a day - that would destroy the SVG tag structure completely.

Ended up using wp_kses() with custom allowlists instead. Had to create two separate allowlists: one for inner SVG content (path, rect, circle elements) and another for the full SVG element with all the viewbox and stroke attributes. Pretty neat how wp_kses() preserves attribute casing in HTML5 output - even though I used lowercase viewbox in the allowlist, it still works with the proper SVG spec viewBox.

Also cleaned up some dead code in functions.php - removed a CDN reference from our CSP directive since we're now serving motion.js locally. Small wins add up.

Deployment was... interesting. SCP decided to throw "dest open... No such file or directory" errors even though the directory clearly existed. Ended up using the old cat file | ssh server "cat > /path" workaround. Sometimes the classics just work.

The bigger chunk of work was pushing our Vertical Factory to v2. Added a whole new template generator agent that reads our base templates and applies vertical-specific substitutions. It's pretty cool - instead of generating templates from scratch, it preserves all our existing accessibility and schema wiring by doing smart substitutions of nouns, fallbacks, and schema types.

The factory now enforces that ALL 10 required templates are generated before packaging. Learned this the hard way - WordPress doesn't auto-inherit from _base at runtime, so every template needs to be explicit. Added some quality gates to catch this early.

Also expanded our research pipeline with mobile screenshots (iPhone 14 viewport), nav/footer structure extraction, and funnel depth detection. The goal is to classify sites as 2/3/5/7-page structures automatically.

Hit a few bumps along the way. Cloudways API kept returning 404s for cache purging, so fell back to WP-CLI via SSH. And discovered that our memstack database helper is picky about data types - everything needs to be strings, no lists allowed.

Next up is either wiring the 8-layer site assessment to our factory system or building out the page matrix generator for the dashboard. Both are meaty tasks that'll probably eat up most of tomorrow.

The security hardening feels good though. Nothing like properly escaped output to sleep better at night.

Share this post