Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Unified Diff: src/parsing/scanner-character-streams.cc

Issue 2663773002: [scanner] Fix bom handling (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/scanner-character-streams.cc
diff --git a/src/parsing/scanner-character-streams.cc b/src/parsing/scanner-character-streams.cc
index b5e9c171da0561ee81dcdd5be0a388cce419c883..d3162dfbb2263bfd5bcb29a0b85346df3ce4d2c1 100644
--- a/src/parsing/scanner-character-streams.cc
+++ b/src/parsing/scanner-character-streams.cc
@@ -15,6 +15,10 @@
namespace v8 {
namespace internal {
+namespace {
+const unibrow::uchar kUtf8Bom = 0xfeff;
+} // namespace
+
// ----------------------------------------------------------------------------
// BufferedUtf16CharacterStreams
//
@@ -263,7 +267,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.
vogelheim 2017/01/30 18:59:32 copy -> count. This loop doesn't copy anything; it
+ } else if (t != unibrow::Utf8::kIncomplete) {
chars++;
if (t > unibrow::Utf16::kMaxNonSurrogateCharCode) chars++;
}
@@ -304,8 +310,6 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() {
return;
}
- static const unibrow::uchar kUtf8Bom = 0xfeff;
-
unibrow::Utf8::Utf8IncrementalBuffer incomplete_char =
current_.pos.incomplete_char;
size_t it;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698