diff options
| author | Luca Casonato <lucacasonato@yahoo.com> | 2021-01-05 19:50:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-05 19:50:40 +0100 |
| commit | 0d41e21b0e9b46cc179eff42c215439fb672964b (patch) | |
| tree | ec61f2e543de43f3633bcab17a4eb0fdb34aab06 /core | |
| parent | ee9c0c837331528653f959d57f094a8dbfdaacce (diff) | |
fix: align encoding APIs to spec using WPT (#9004)
Diffstat (limited to 'core')
| -rw-r--r-- | core/bindings.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index d9c875e60..eb46e6ef2 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -654,6 +654,14 @@ fn decode( ) }; + // Strip BOM + let buf = + if buf.len() >= 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf { + &buf[3..] + } else { + buf + }; + // If `String::new_from_utf8()` returns `None`, this means that the // length of the decoded string would be longer than what V8 can // handle. In this case we return `RangeError`. |
