这是indexloc提供的服务,不要输入任何密码
Skip to content

WebGPU: Forbid null code point '\0' (U+0000) within strings #3576

@jiangzhaoming

Description

@jiangzhaoming

(Edited: bold the proposal)

Proposal

Currently WebGPU Spec use USVString and DOMSrting in several places (listed below) including user input.

For both type a string with a null character '\0' (i.e. Unicode code point U+0000) in it is valid, e.g. "abc\0xyz" would be valid DOMString and USVString, however such kind of strings is kind of tricky in other languages like C/C++.

Currently the WGSL spec explicitly forbid the null code point (U+0000) in WGSL program. Although using a string with '\0' in it in some case like entryPoint should be a validation error (since there must not be a WGSL entry point name containing '\0'), it may be generally better and easier to forbid any '\0' in all string user providing to WebGPU. It would be coherent to report a JavaScript TypeError whenever any user-provided string was found to contain a '\0'.

I am not quite sure how to introduce such rule into WebGPU spec, considering USVString and DomString are used multiple times in different places within the spec. Maybe add a small sub-chapter under Chapter 3. Fundamentals?

Current usage

Currently USVString and DomString are used in WebGPU spec for:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions