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

Define the supported HTML subset for message events #1562

Merged
merged 6 commits into from
Aug 28, 2018

Conversation

turt2live
Copy link
Member

Rendered: see 'docs' status check


Also clarify that m.notice messages can support HTML.

Reference: https://github.com/matrix-org/matrix-react-sdk/blob/2dc94ac277bfaed6e7a8116ff08bba22ee8fb642/src/HtmlUtils.js#L179-L291

Fixes #1559
Fixes #1560

Also clarify that `m.notice` messages can support HTML.

Fixes matrix-org#1559
Fixes matrix-org#1560
@turt2live turt2live requested a review from a team August 26, 2018 04:58
``class`` (only classes which start with ``language-`` for syntax highlighting)


Additionally, clients should ensure that *all* ``a`` tags get a ``rel="noopener"``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/clients/web clients/

Copy link
Contributor

@Half-Shot Half-Shot Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to keeping tables, lots of bots n things use it. The discord bridge will be using it to display discords tables in clients.


Apparently FastHub (android client) has rendered all inline comments in one thread, will move this comment when at a PC

injection, and similar attacks. The strongly suggested set of HTML tags to permit,
denying the use and rendering of anything else, is: ``font``, ``del``, ``h1``,
``h2``, ``h3``, ``h4``, ``h5``, ``h6``, ``blockquote``, ``p``, ``a``, ``ul``,
``ol``, ``sup``, ``sub``, ``nl``, ``li``, ``b``, ``i``, ``u``, ``strong``, ``em``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have no idea what nl is doing in there. i'd be inclined to remove it.


:``img``:
``width``, ``height``, ``alt``, ``title``, ``src`` (provided it is a Matrix Content
URI)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"provided it uses the mxc:// scheme" perhaps

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is that people generally don't know how the media repository works, or what an "mxc://" scheme is. To be fair, a "Matrix Content URI" also doesn't click.

A link on mxc:// maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that making "Matrix Content URI" to the section where it's defined (#module-content) would be helpful. In that section, it's called "Matrix Content (MXC) URI", so I think we should go with that.

plain text version of the HTML should be provided in the ``body``.

Clients should limit the HTML they render to avoid Cross-Site Scripting, HTML
injection, and similar attacks. The strongly suggested set of HTML tags to permit,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also specify a maximum nesting of the tags, to avoid thousands of nested b-tags crashing browsers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does arbitrarily picking the number 42 seem reasonable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ftr went with 100 further down

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i was worried with 42 being too small given scope for legitimate nesting from RTE copy-paste antics)

to display if available. Currently ``m.text``, ``m.emote``, and ``m.notice``
support an additional ``format`` parameter of ``org.matrix.custom.html``. When
this field is present, a ``formatted_body`` with the HTML must be provided. The
plain text version of the HTML should be provided in the ``body``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth a informational link through to #1225 as an FYI on how this might evolve in general, to reassure people we're not baking in the crappy formatted_body thing forever. (do we have a way of doing informational blocks in the spec atm, which aren't normative but just FYI?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a "note" which ends up being a dark gray box of text.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a note further down

``h2``, ``h3``, ``h4``, ``h5``, ``h6``, ``blockquote``, ``p``, ``a``, ``ul``,
``ol``, ``sup``, ``sub``, ``nl``, ``li``, ``b``, ``i``, ``u``, ``strong``, ``em``,
``strike``, ``code``, ``hr``, ``br``, ``div``, ``table``, ``thead``, ``tbody``,
``tr``, ``th``, ``td``, ``caption``, ``pre``, ``span``, ``img``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we remove the table stuff (table, thead, tbody, tr, th, td, caption) from this list as nobody uses it, and it makes implementation much harder on non-web-based clients. We could include it as a "you could always whitelist this if your client can render it safely, but it's not currently recommended" perhaps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use tables all the time in various alerts from things. It's the closest we have to arbitrary fields like slack.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay.

@ara4n
Copy link
Member

ara4n commented Aug 27, 2018

lgtm other than comments

@turt2live turt2live requested a review from ara4n August 27, 2018 15:17
@turt2live turt2live removed their assignment Aug 27, 2018
Copy link
Member

@ara4n ara4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@turt2live turt2live merged commit e4f8c23 into matrix-org:master Aug 28, 2018
@turt2live turt2live deleted the travis/c2s/html-formatting branch August 28, 2018 01:14
RiotTranslateBot pushed a commit to RiotTranslateBot/matrix-doc that referenced this pull request Aug 22, 2023
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.

4 participants