Skip to content

Add support for trusted-types and require-trusted-types #4

@kingthorin

Description

@kingthorin

It would be nice to have handling for: the trusted-types trusted-types and require-trusted-types-for require-trusted-types-for directives.

This advice was provided pre-fork:


The process will be basically

  • define new Value Value kinds for new directive values which are more complex than just a boolean. At a glance, you probably want a special Value kind for tt-policy-name, but the others look like they can be handled as booleans on the directive.
  • define new Directives Directive kind for both new directives (trusted-types trusted-types) and (require-trusted-types-for require-trusted-types-for)
  • add helpers to allow reading and writing their attributes, and ensure that updating keeps their internal values field up to date (by using the addValue and removeValueIgnoringCase helpers, mainly)
  • define new Value Value kinds for new directive values which are more complex than just a boolean. At a glance, you probably want a special Value kind for tt-policy-name, but the others look like they can be handled as booleans on the directive.
  • define new Directives Directive kind for both new directives ("trusted-types" and ("require-trusted-types-for")
  • add helpers to allow reading and writing their attributes, and ensure that updating keeps their internal values field up to date (by using the addValue and removeValueIgnoringCase helpers, mainly)
  • update the parser to handle them
  • add tests

The main challenges in my experience is figuring out what the spec is trying to say and whether that's actually what browsers do. For example, it says the syntax is defined by an ABNF, which means keywords are case-insensitive ("ABNF strings are case insensitive"). So per spec, 'ALLow-DUPlicATES' is a legal way to write 'allow-duplicates'. Is that actually intentional? Is that what browsers do? Gotta check. Similarly, are policy names case-sensitive or not? That affects the representation and especially the manipulation of those Values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions