XML parser always sets xmlVersion to the same value
|
ErrorOr<void, ParseError> Parser::parse_version_info() |
|
{ |
|
auto rollback = rollback_point(); |
|
auto rule = enter_rule(); |
|
|
|
// VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') |
|
TRY(skip_whitespace(Required::Yes)); |
|
TRY(expect("version"sv)); |
|
auto accept = accept_rule(); |
|
|
|
TRY(parse_eq()); |
|
TRY(expect(is_any_of("'\""sv), "one of ' or \""sv)); |
|
m_lexer.retreat(); |
|
|
|
auto version_string = m_lexer.consume_quoted_string(); |
|
if (version_string == "1.0") { |
|
// FIXME: Compatibility mode, figure out which rules are different in XML 1.0. |
|
m_version = Version::Version10; |
|
m_in_compatibility_mode = true; |
|
} else { |
|
if (version_string != "1.1" && m_options.treat_errors_as_fatal) |
|
return parse_error(m_lexer.current_position(), ByteString::formatted("Expected '1.1', found '{}'", version_string)); |
|
} |
|
|
|
m_version = Version::Version11; |
|
rollback.disarm(); |
|
return {}; |
|
} |
As we do not support
xmlVersion property, I didn't find a way to test this within js, but the current code is kind of misleading and it's easy to suppose Version::Version10 is set when required, whereas it is always overridden with Version::Version11