Skip to content

Clipping of violation’s sample to the 40 first characters #704

Open
@fred-wang

Description

@fred-wang

See

https://w3c.github.io/webappsec-csp/#framework-violation
https://w3c.github.io/webappsec-csp/#should-block-inline
https://w3c.github.io/webappsec-csp/#can-compile-strings

The spec says "the substring of source containing its first 40 characters".

I understand this means a surrogate pair in the violation sample should be treated as a single character, but maybe that needs to be mentioned explicitly and/or to be covered by specific WPT tests.

Currently, Firefox instead just clips the source as UTF-16 string of length 40 which is somehow a bit easier (but has special code to avoid clipping the last character in the middle of a surrogate pair): https://bugzilla.mozilla.org/show_bug.cgi?id=1935996

I wonder what Chromium or WebKit do?

cc @lukewarlow @koto

(incidentally, probably a separate issue but Firefox may also append an ellipsis character to indicate that the content was really clipped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs testsMoving the issue forward requires someone to write tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions