Closed Bug 1457233 Opened 7 years ago Closed 6 years ago

Allow AS router message content to include subset of HTML

Categories

(Firefox :: Messaging System, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 62
Iteration:
62.3 - Jun 18
Tracking Status
firefox62 --- fixed

People

(Reporter: k88hudson, Assigned: andreio)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Snippets need to be able to include some HTML in messages such as links, bold/italic styling, etc. For example: { "content": { "text": "Click this <a href='https://mozilla.org/whatever'>link</a>!" } } We should allow some tags and attributes to be rendered in a secure way. This could include React elements as well as standard DOM elements. Perhaps we could do something along the same lines of what the fluent project is using? [1] [1] https://github.com/projectfluent/fluent.js/blob/8e4f284e04b9333393da8c66dca46d82f3e60b57/fluent-react/src/markup.js#L5
Blocks: 1432588
Severity: normal → enhancement
Iteration: --- → 62.1 - May 21
Priority: -- → P2
Iteration: 62.1 - May 21 → 62.2 - Jun 4
Assignee: nobody → andrei.br92
Iteration: 62.2 - Jun 4 → 62.1 - May 21
Priority: P2 → P1
(In reply to Kate Hudson :k88hudson from comment #0) > We should allow some tags and attributes to be rendered in a secure way. > This could include React elements as well as standard DOM elements. Are you going to support _some_ tags or all HTML. Right now Snippets does not limit the included HTML
Flags: needinfo?(khudson)
We're only going to support only a whitelist for security reasons and to make sure we're keeping with the design parameters of the template (for example, we wouldn't allow style or script tags). To what extent is HTML used now? Is it mostly for anchor tags / bold / italic / underline, or are there more complex use cases currently?
Flags: needinfo?(khudson)
Iteration: 62.1 - May 21 → 62.2 - Jun 4
(In reply to Kate Hudson :k88hudson from comment #2) > We're only going to support only a whitelist for security reasons and to > make sure we're keeping with the design parameters of the template (for > example, we wouldn't allow style or script tags). To what extent is HTML > used now? Is it mostly for anchor tags / bold / italic / underline, or are > there more complex use cases currently? I think supporting the basic tags you list should be enough. Could we get a document of all the supported tags so we can validate on our side?
Flags: needinfo?(khudson)
Flags: needinfo?(andrei.br92)
That sounds like a good idea,:andreio can you add a list of supported html tags to the docs somewhere when you implement this?
Flags: needinfo?(khudson)
So the following tags are allowed: i, b, u, strong, em, br If an element that is not on the list is used, the text content will be extracted and displayed. Grouping multiple allowed elements is not possible, only the first level will be used: “<u><b>text</b></u>” will be interpreted as “<u>text</u>”. Links are more difficult with fluent because you cannot pass href attributes. Here is an example of how snippets would have to provide content: { "text": "Here is a <downloadLink>download link</downloadLink> and here is our <privacyLink>privacy notice</privacyLink>." "links": { "downloadLink": { "url": "https://..." }, "privacyLink": { "url": "https://..." } } } This format would allow us to do 1 or more links using fluent. Let me know if this works with snippets-service.
Flags: needinfo?(andrei.br92) → needinfo?(giorgos)
Flags: needinfo?(giorgos)
Agreed on the format and the allowed tags. FTR this way of A HREF formatting is to help translations and it's equivalent to the {% trans link=http://example.com %} blocks we use in Jinja.
Andrei can you please update the message schemas to capture this?
Flags: needinfo?(andrei.br92)
Flags: needinfo?(andrei.br92)
The links should allow for custom metric type, i.e. something different than 'click'. The current system workings are documented here: - https://abouthome-snippets-service.readthedocs.io/en/latest/developing.html#custom-metric-pings I suggest that we include this in the schema as: { "text": "Here is a <downloadLink>download link</downloadLink> and here is our <privacyLink>privacy notice</privacyLink>." "links": { "downloadLink": { "url": "https://..." "metric": "download-click" }, "privacyLink": { "url": "https://..." } } } If 'metric' does not exist, it must default to 'click'.
Flags: needinfo?(andrei.br92)
Iteration: 62.2 - Jun 4 → 62.3 - Jun 18
Andrei, I just talked to nan and it sounds like you two were talking about using the "value" field for this kind of custom metric type, which sounds good to me. Are you going to add that in this PR or do it a follow-up?
The schema for the message giorgos posted looks good to me btw
Flags: needinfo?(andrei.br92)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Blocks: 1467858
Blocks: 1469938
Component: Activity Streams: Newtab → Messaging System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: