Page MenuHomePhabricator

Codex-PHP: Improve plain text vs raw HTML handling using HtmlSnippet
Open, Needs TriagePublic

Description

Right now, some setters take plain text (e.g. LabelBuilder::setDescription()) and some take raw HTML (e.g. LabelBuilder::setLabelText(), despite the name). This is confusing, not flexible enough, and doesn't promote security. We want it to be clear whether something is plain text or raw HTML, and we want raw HTML to be supported in more places, but we don't want it to be the default to avoid accidentally passing unescaped plain text into something that expects raw HTML.

To address these issues, we should make most of these setters accept either a string or an HtmlSnippet object. When a string is passed in, this should be interpreted as plain text and escaped; when an HtmlSnippet is passed in this should be interpreted as raw HTML and not escaped. This way it's always clear what's HTML and what's plain text. Some setters may need to only accept a string, if they only accept plain text and it doesn't make sense for them to accept raw HTML.

Event Timeline

Change #1204692 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex-php@main] [BREAKING CHANGE] Use strings for plain text, HtmlSnippets for raw HTML

https://gerrit.wikimedia.org/r/1204692

Change #1204692 merged by jenkins-bot:

[design/codex-php@main] [BREAKING CHANGE] Use strings for plain text, HtmlSnippets for raw HTML

https://gerrit.wikimedia.org/r/1204692