How fast can you validate UTF-8 strings in JavaScript?
1–10 of 18 posts
Re: How fast can you validate UTF-8 strings in JavaScript?
#2Re: How fast can you validate UTF-8 strings in JavaScript?
#3The article claims that accepting 'invalid' UTF-8 can be a security risk. Can someone explain how?
Re: How fast can you validate UTF-8 strings in JavaScript?
#4Re: How fast can you validate UTF-8 strings in JavaScript?
#5The article claims that accepting 'invalid' UTF-8 can be a security risk. Can someone explain how?
Re: How fast can you validate UTF-8 strings in JavaScript?
#6Not tested is https://www.npmjs.com/package/utf-8-validate (1,624,873 weekly downloads) - which I use.
> This C++ library is part of the JavaScript package utf-8-validate. The utf-8-validate package is routinely downloaded more than a million times per week.
> If you are using Node JS (19.4.0 or better), you already have access to this function as buffer.isUtf8(input).
And at https://github.com/websockets/utf-8-validate/tree/master/dep...
> # Reference
> John Keiser, Daniel Lemire, [Validating UTF-8 In Less Than One Instruction Per Byte](https://arxiv.org/abs/2010.03090), Software: Practice & Experience 51 (5), 2021
Re: How fast can you validate UTF-8 strings in JavaScript?
#7The article claims that accepting 'invalid' UTF-8 can be a security risk. Can someone explain how?
As on example, you could mislead users by replacing valid codepoints (characters) with visually identical ones, for example in URLs.
Re: How fast can you validate UTF-8 strings in JavaScript?
#8The article claims that accepting 'invalid' UTF-8 can be a security risk. Can someone explain how?
As on example, you could mislead users by replacing valid codepoints (characters) with visually identical ones, for example in URLs.
Re: How fast can you validate UTF-8 strings in JavaScript?
#9Earlier quoted context omitted.
As on example, you could mislead users by replacing valid codepoints (characters) with visually identical ones, for example in URLs.
Wouldn’t "visually identical” tokens still be valid utf8?