Skip to content

v0.2.0

Latest

Choose a tag to compare

@rsmple rsmple released this 18 Sep 23:44

Server templates

Two new rules for HTML written by a template engine: Jinja, Django, Nunjucks, Twig, Blade, ERB, EJS, Handlebars, PHP, JSP and Liquid. They run on @html-eslint/parser, and the new templateEngineSyntax export gives its delimiters for each engine. The engine comes from settings['template-security'].engine or the file extension. See Server templates.

  • no-unsafe-output-context reports output where HTML escaping does not protect it: <script> content, event handlers and htmx/Alpine code attributes, srcdoc, unquoted values (autofixed by adding quotes) and attribute names. The check on the start of URL attributes is opt-in with urls: true.
  • no-unescaped-output reports output that skips escaping: |safe, |raw, {!! !!}, {{{ }}}, <%== %>, raw / html_safe, <%- %>, PHP echo, JSP ${} and {% autoescape false %}.

Both rules were checked on ten open-source projects, one per engine, about 1,540 templates in all.

htmx and Alpine

  • no-unsafe-html treats Alpine's x-html as an HTML sink. It also reports htmx requests (hx-get, hx-post, …) to another origin, because htmx inserts the HTML that origin returns into the page. A new trustedHosts option exempts your own hosts.
  • no-mixed-content checks htmx request attributes on any element, plus sse-connect and ws-connect. It reports ws: URLs and suggests wss:.
  • no-html-with-children covers x-html.

Qwik and MDX

Both work through the JSX support as they are. They are now documented and covered by an end-to-end test.

Other changes

  • The plugin's meta now reads the name and version from package.json.
  • The no-mixed-content suggestion is now named useSecure instead of useHttps, since it also covers wss:.