diff options
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`. |