| Summary: | [WebGPU] WebGPU strings are UTF-8, not Latin-1 | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Myles C. Maxfield <mmaxfield> | ||||
| Component: | WebGPU | Assignee: | Myles C. Maxfield <mmaxfield> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | darin, dino, djg, kkinnunen, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Bug Depends on: | 239056 | ||||||
| Bug Blocks: | |||||||
| Attachments: |
|
||||||
|
Description
Myles C. Maxfield
2022-04-10 18:33:34 PDT
Created attachment 457219 [details]
Patch
Comment on attachment 457219 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457219&action=review > Source/WebGPU/WebGPU/Adapter.mm:137 > + auto label = String::fromUTF8(descriptor.label); Aren't these coming from the API? E.g. would fromAPI() be more appropriate? Comment on attachment 457219 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457219&action=review >> Source/WebGPU/WebGPU/Adapter.mm:137 >> + auto label = String::fromUTF8(descriptor.label); > > Aren't these coming from the API? E.g. would fromAPI() be more appropriate? Good point. Committed r292748 (?): <https://commits.webkit.org/r292748> Comment on attachment 457219 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457219&action=review > Source/WebGPU/ChangeLog:8 > + Replace String::fromLatin1() with String::fromUTF8(). Great to fix this if it was going to mishandle non-ASCII characters. But note that now there is a failure case for all of these, if it’s invalid UTF-8. This is a major difference between String::fromUTF8 and String::fromLatin1, and might eventually lead to us renaming it to String::tryFromUTF8. As long as each caller either has a guarantee it will be valid UTF-8, or can withstand a null string result when it’s not, we are OK. Comment on attachment 457219 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457219&action=review >> Source/WebGPU/ChangeLog:8 >> + Replace String::fromLatin1() with String::fromUTF8(). > > Great to fix this if it was going to mishandle non-ASCII characters. But note that now there is a failure case for all of these, if it’s invalid UTF-8. This is a major difference between String::fromUTF8 and String::fromLatin1, and might eventually lead to us renaming it to String::tryFromUTF8. > > As long as each caller either has a guarantee it will be valid UTF-8, or can withstand a null string result when it’s not, we are OK. Right. For this situation, it's the latter. |