Index: Source/modules/encoding/TextDecoder.cpp |
diff --git a/Source/modules/encoding/TextDecoder.cpp b/Source/modules/encoding/TextDecoder.cpp |
index 84df22cad1c6f5b8fa545d123d5e612747d6da51..9e93b705f5d49b742a96c514226dbfb7420a50e4 100644 |
--- a/Source/modules/encoding/TextDecoder.cpp |
+++ b/Source/modules/encoding/TextDecoder.cpp |
@@ -51,14 +51,18 @@ TextDecoder* TextDecoder::create(const String& label, const Dictionary& options, |
bool fatal = false; |
options.get("fatal", fatal); |
- return new TextDecoder(encoding.name(), fatal); |
+ bool ignoreBOM = false; |
+ options.get("ignoreBOM", ignoreBOM); |
+ |
+ return new TextDecoder(encoding.name(), fatal, ignoreBOM); |
} |
-TextDecoder::TextDecoder(const String& encoding, bool fatal) |
+TextDecoder::TextDecoder(const String& encoding, bool fatal, bool ignoreBOM) |
: m_encoding(encoding) |
, m_codec(newTextCodec(m_encoding)) |
, m_fatal(fatal) |
+ , m_ignoreBOM(ignoreBOM) |
, m_bomSeen(false) |
{ |
} |
@@ -95,7 +99,7 @@ String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex |
return String(); |
} |
- if (!m_bomSeen && !s.isEmpty()) { |
+ if (!m_ignoreBOM && !m_bomSeen && !s.isEmpty()) { |
m_bomSeen = true; |
String name(m_encoding.name()); |
if ((name == "UTF-8" || name == "UTF-16LE" || name == "UTF-16BE") && s[0] == 0xFEFF) |