Skip to content

Set the nonce attribute on inline style tags created by the output processor #2665

Open
@christianp

Description

@christianp

Content security policies can specify a value for the nonce that must be present on all inline styles, in the style-src part of the directive. When a nonce is specified, the unsafe-inline directive is ignored.

The idea is to prevent styles included in user-supplied content from being applied. The nonce should be different each time the page is loaded, so this only protects against content that doesn't change with each page load.

The Google closure library resolves this by finding a <script> tag in the page with the nonce attribute, and using that. There isn't always one of those, so it should be possible to pass it as an option in the MathJax config, too.

I'm looking at this today to get the MathJax integration on mastodon working, so I might have a pull request soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code ExampleContains an illustrative code example, solution, or work-aroundFeature Requestv3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions