Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Attributes: Don't stringify values as it breaks Trusted Types #4948

Closed
Assignees
mgol
Milestone
@mgol

Description

@mgol

Originally posted by@koto in#4409 (comment)

I noticed one violation still injQuery.attr, where the value of the attributeis stringified before callingsetAttribute:

const policy = trustedTypes.createPolicy('a', {createScriptURL: s=>s})jQuery(aScript, policy.createScriptURL('foo'));Uncaught TypeError: Failed to execute 'setAttribute' on 'Element': This document requires 'TrustedScriptURL' assignment.    at attr (jquery.js:6997)    at access (jquery.js:3467)    at jQuery.fn.init.attr (jquery.js:6955)    at <anonymous>:1:6

There is a workaround via.attr hooks, but it might be worth addressing nonetheless.

It seems like this was introduced inff75767, I suspect to workaround anIE <= 9 bug, which incorrectly stringified objects passed tosetAttribute.

I'm not sure what the most elegant solution would be here, I guess it depends on whether jQuery 4 aims to support IE9. If not, it's safe not to stringify values (browser API would). If yes, then there's only a less-than-ideal option of testing for the bug? IIRC this would be a good test:

with (document.createElement('div')) {  setAttribute('title', {toString:()=>''});   getAttribute('title') === ''}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp