Skip to content

Move authoring UI inline JS handlers to data attributes - #168

Open
snoopdave wants to merge 2 commits into
masterfrom
authoring-ui-event-handlers
Open

Move authoring UI inline JS handlers to data attributes#168
snoopdave wants to merge 2 commits into
masterfrom
authoring-ui-event-handlers

Conversation

@snoopdave

Copy link
Copy Markdown
Contributor

Several authoring pages embed values in inline JavaScript string literals and
then write them into the page with jQuery .html(). This refactor moves those
values into data attributes and writes them through text APIs, so JSPs stop
hand-concatenating markup and data.

What changed

  • Move server/user-controlled values out of inline JavaScript string literals
    into double-quoted, HTML-escaped data-* attributes.
  • Bind delegated event listeners that read values as text and assign them via
    textContent, .text(), .val(), or DOM constructors.
  • Replace the affected .html() writes with a text API.
  • Use double-quoted attributes for weblog-content values in the media views.
  • Cover templates, bookmarks/folders, categories, media views/chooser/success,
    entry lists, and entry editing, including the category iterator and
    delete-modal cases.
  • Render theme descriptions as text and make ThemeDataServlet return valid
    JSON.

Tests

  • Values containing apostrophes, quotes, angle brackets, backslashes, newlines,
    and </script> remain text through each path.
  • Cross-user authoring cases confirm one author's values stay text in another
    author or administrator session.
  • A source audit confirms no affected value remains in an inline literal, a
    single-quoted attribute, or a .html() sink.

The editor screens built handler arguments by interpolating template values
directly into inline onclick/onchange attributes. Those values now travel in
data-* attributes and are read back through delegated listeners, which matches
how the rest of the UI binds behaviour and keeps markup and data separate.

Writes that placed those values into the DOM now use text APIs rather than
html(), and ThemeDataServlet escapes its JSON output so theme metadata cannot
produce a malformed document.

Adds AuthoringUiSinkAuditTest to keep the editor templates on this pattern.
The media gallery rendered the media file name into single-quoted HTML
attributes; those attributes are now double-quoted so the value stays data.
The sink-audit test description now states the rule it enforces, and the
repeated per-page comment is collapsed to one line.

Claude-Session: https://claude.ai/code/session_01A1fhY1E2PCFU6UAPXu2WtV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant