RESOLVED FIXED 239057
[WebGPU] WebGPU strings are UTF-8, not Latin-1
https://bugs.webkit.org/show_bug.cgi?id=239057
Summary [WebGPU] WebGPU strings are UTF-8, not Latin-1
Myles C. Maxfield
Reported 2022-04-10 18:33:34 PDT
.
Attachments
Patch (5.12 KB, patch)
2022-04-10 18:36 PDT, Myles C. Maxfield
kkinnunen: review+
Myles C. Maxfield
Comment 1 2022-04-10 18:36:42 PDT
Kimmo Kinnunen
Comment 2 2022-04-11 01:23:44 PDT
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?
Myles C. Maxfield
Comment 3 2022-04-11 17:34:23 PDT
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.
Myles C. Maxfield
Comment 4 2022-04-11 17:40:39 PDT
Radar WebKit Bug Importer
Comment 5 2022-04-11 17:41:16 PDT
Darin Adler
Comment 6 2022-04-12 12:30:03 PDT
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.
Myles C. Maxfield
Comment 7 2022-04-12 15:40:49 PDT
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.
Note You need to log in before you can comment on or make changes to this bug.