| Index: src/parsing/scanner-character-streams.cc
|
| diff --git a/src/parsing/scanner-character-streams.cc b/src/parsing/scanner-character-streams.cc
|
| index 7ebf2fe724cc8409d9fa530e74f9e7c55e6ca327..f7c7fd526f90a50440e479d840852a3b7b863603 100644
|
| --- a/src/parsing/scanner-character-streams.cc
|
| +++ b/src/parsing/scanner-character-streams.cc
|
| @@ -14,6 +14,10 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +namespace {
|
| +const unibrow::uchar kUtf8Bom = 0xfeff;
|
| +} // namespace
|
| +
|
| // ----------------------------------------------------------------------------
|
| // BufferedUtf16CharacterStreams
|
| //
|
| @@ -259,7 +263,9 @@ bool Utf8ExternalStreamingStream::SkipToPosition(size_t position) {
|
| while (it < chunk.length && chars < position) {
|
| unibrow::uchar t =
|
| unibrow::Utf8::ValueOfIncremental(chunk.data[it], &incomplete_char);
|
| - if (t != unibrow::Utf8::kIncomplete) {
|
| + if (t == kUtf8Bom && current_.pos.chars == 0) {
|
| + // BOM detected at beginning of the stream. Don't copy it.
|
| + } else if (t != unibrow::Utf8::kIncomplete) {
|
| chars++;
|
| if (t > unibrow::Utf16::kMaxNonSurrogateCharCode) chars++;
|
| }
|
| @@ -300,8 +306,6 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() {
|
| return;
|
| }
|
|
|
| - static const unibrow::uchar kUtf8Bom = 0xfeff;
|
| -
|
| unibrow::Utf8::Utf8IncrementalBuffer incomplete_char =
|
| current_.pos.incomplete_char;
|
| size_t it;
|
|
|