Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dodge nasty HTML in data content more aggressively #269

Merged
merged 3 commits into from
Sep 11, 2023

Conversation

towerofnix
Copy link
Member

This is somewhat scary stuff, but appears to all be working correctly. 🏴‍☠️

This PR does not guarantee thorough sanitization of content sourced from data files, but it does running into unexpected issues hopefully much less common of an occurrence.

Notable changes:

  • formatString (aka language.$) now HTML-escapes all string arguments provided.
  • formatString now returns its results wrapped in a nameless, attributeless tag, indicating that its results are "sanitized" and shouldn't be sanitized by later calls to formatString.
  • Same changes for list formatting utilities (new private utilities #sanitizeStringArg and #wrapSanitized do the heavy lifting).
  • Template now accepts HTML in {type: 'string'} arguments. These are automatically stringified (.toString()) before being exposed to the description's content(slots) function (or generate(slots)). This is so that these can still accept "strings" returned from formatString (which are wrapped in tags now).
  • In cases where a formatted or non-formatted string may be provided, and will be directly embedded in HTML rather than passed as an argument to formatString, the new utility language.sanitize() will escape HTML in non-formatted strings (and return the results wrapped in a tag).
    • This is only used in generateCoverGrid at the moment, but there are potentially more cases that would benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant