Skip to content

feat(build): fail the build on post markup that runs code - #122

Merged
bits-bytes-nn merged 1 commit into
mainfrom
feat/safe-post-html
Nov 11, 2026
Merged

bits-bytes-nn merged 1 commit into
mainfrom
feat/safe-post-html

Conversation

@bits-bytes-nn

Copy link
Copy Markdown
Owner

Summary

  • Adds _plugins/safe_post_html.rb: a post_convert hook that parses each post's rendered body with Nokogiri's HTML5 parser and fails the build on markup that would run code or load a document: active elements (script, object, base, meta, form, ...), on*/srcdoc/formaction attributes, and URL attributes whose scheme is not http(s), mailto, tel, relative, an anchor, or an inline image.
  • It checks kramdown's output, so raw HTML, links, images and attribute lists are all judged as the browser reads them (entities decoded). Code blocks are text and pass.
  • Generated posts arrive as PRs, so a failing build blocks the merge instead of rewriting the post.

Test plan

  • ruby test/run_all.rb: 192 runs, 0 failures (15 active and 11 safe cases added)
  • bundle exec jekyll build: all 38 existing posts build unchanged
  • A scratch post with <img onerror> fails the build with the post path; the same text in a code span builds

A post_convert hook parses each rendered post body with an HTML5 parser and rejects active elements, event handler and srcdoc/formaction attributes, and URL attributes with schemes posts do not use. Code blocks are text by then and pass.
@bits-bytes-nn
bits-bytes-nn merged commit 361ff1f into main Nov 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant