Skip to content

Conversation

@pizza-day
Copy link

Replaces pull request #6. That fix was a band aid, so I looked into a way to make this more robust. Hence this new pull request.

Use the type system to help avoid XSS/script injection vulnerabilities. Introduces a new SafeHtml type string can only be constructed from:

  • a string which has been sanitized (i.e. <>&"' characters replaced with HTML entities)
  • a literal string, enforced by the 'static lifetime annotation
  • concatenations of already constructed SafeHtml strings

A SafeHtml string cannot be constructed from unsanitized user input, and this is enforced by the type system. This is not a complete guarantee of safety against injection. You could specify "<script>" as a string literal and it would be considered safe. But this makes the code easier to audit.

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