@@ -871,7 +871,7 @@ class OurFeatures {
871
871
bool failIfExtra_;
872
872
bool rejectDupKeys_;
873
873
bool allowSpecialFloats_;
874
- bool allowBom_ ;
874
+ bool skipBom_ ;
875
875
size_t stackLimit_;
876
876
}; // OurFeatures
877
877
@@ -940,7 +940,7 @@ class OurReader {
940
940
941
941
bool readToken (Token& token);
942
942
void skipSpaces ();
943
- void skipBom (bool allowBom );
943
+ void skipBom (bool skipBom );
944
944
bool match (const Char* pattern, int patternLength);
945
945
bool readComment ();
946
946
bool readCStyleComment (bool * containsNewLineResult);
@@ -1025,7 +1025,7 @@ bool OurReader::parse(const char* beginDoc, const char* endDoc, Value& root,
1025
1025
nodes_.push (&root);
1026
1026
1027
1027
// skip byte order mark if it exists at the beginning of the UTF-8 text.
1028
- skipBom (features_.allowBom_ );
1028
+ skipBom (features_.skipBom_ );
1029
1029
bool successful = readValue ();
1030
1030
nodes_.pop ();
1031
1031
Token token;
@@ -1272,10 +1272,9 @@ void OurReader::skipSpaces() {
1272
1272
}
1273
1273
}
1274
1274
1275
- void OurReader::skipBom (bool allowBom) {
1276
- // If BOM is not allowed, then skip it.
1277
- // The default value is: false
1278
- if (!allowBom) {
1275
+ void OurReader::skipBom (bool skipBom) {
1276
+ // The default behavior is to skip BOM.
1277
+ if (skipBom) {
1279
1278
if (strncmp (begin_, " \xEF\xBB\xBF " , 3 ) == 0 ) {
1280
1279
begin_ += 3 ;
1281
1280
current_ = begin_;
@@ -1900,7 +1899,7 @@ CharReader* CharReaderBuilder::newCharReader() const {
1900
1899
features.failIfExtra_ = settings_[" failIfExtra" ].asBool ();
1901
1900
features.rejectDupKeys_ = settings_[" rejectDupKeys" ].asBool ();
1902
1901
features.allowSpecialFloats_ = settings_[" allowSpecialFloats" ].asBool ();
1903
- features.allowBom_ = settings_[" allowBom " ].asBool ();
1902
+ features.skipBom_ = settings_[" skipBom " ].asBool ();
1904
1903
return new OurCharReader (collectComments, features);
1905
1904
}
1906
1905
static void getValidReaderKeys (std::set<String>* valid_keys) {
@@ -1916,7 +1915,7 @@ static void getValidReaderKeys(std::set<String>* valid_keys) {
1916
1915
valid_keys->insert (" failIfExtra" );
1917
1916
valid_keys->insert (" rejectDupKeys" );
1918
1917
valid_keys->insert (" allowSpecialFloats" );
1919
- valid_keys->insert (" allowBom " );
1918
+ valid_keys->insert (" skipBom " );
1920
1919
}
1921
1920
bool CharReaderBuilder::validate (Json::Value* invalid) const {
1922
1921
Json::Value my_invalid;
@@ -1951,7 +1950,7 @@ void CharReaderBuilder::strictMode(Json::Value* settings) {
1951
1950
(*settings)[" failIfExtra" ] = true ;
1952
1951
(*settings)[" rejectDupKeys" ] = true ;
1953
1952
(*settings)[" allowSpecialFloats" ] = false ;
1954
- (*settings)[" allowBom " ] = false ;
1953
+ (*settings)[" skipBom " ] = true ;
1955
1954
// ! [CharReaderBuilderStrictMode]
1956
1955
}
1957
1956
// static
@@ -1968,7 +1967,7 @@ void CharReaderBuilder::setDefaults(Json::Value* settings) {
1968
1967
(*settings)[" failIfExtra" ] = false ;
1969
1968
(*settings)[" rejectDupKeys" ] = false ;
1970
1969
(*settings)[" allowSpecialFloats" ] = false ;
1971
- (*settings)[" allowBom " ] = false ;
1970
+ (*settings)[" skipBom " ] = true ;
1972
1971
// ! [CharReaderBuilderDefaults]
1973
1972
}
1974
1973
0 commit comments