diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc b/chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc index bdeea6241c2..a6d21c40db0 100644 --- a/chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc +++ b/chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc @@ -37,7 +37,7 @@ #include <memory> #include "base/auto_reset.h" -#include "base/stl_util.h" +#include "base/cxx17_backports.h" #include "third_party/blink/renderer/core/css/style_engine.h" #include "third_party/blink/renderer/core/dom/cdata_section.h" #include "third_party/blink/renderer/core/dom/comment.h" @@ -707,8 +707,8 @@ scoped_refptr<XMLParserContext> XMLParserContext::CreateMemoryParser( InitializeLibXMLIfNecessary(); // appendFragmentSource() checks that the length doesn't overflow an int. - xmlParserCtxtPtr parser = - xmlCreateMemoryParserCtxt(chunk.c_str(), chunk.length()); + xmlParserCtxtPtr parser = xmlCreateMemoryParserCtxt( + chunk.c_str(), base::checked_cast<int>(chunk.length())); if (!parser) return nullptr; @@ -981,10 +981,15 @@ void XMLDocumentParser::StartElementNs(const AtomicString& local_name, AtomicString adjusted_uri = uri; if (parsing_fragment_ && adjusted_uri.IsNull()) { - if (!prefix.IsNull()) - adjusted_uri = prefix_to_namespace_map_.at(prefix); - else + if (!prefix.IsNull()) { + // TODO(https://crbug.com/1239288) Assign `default_namespace_uri_` to + // `adjusted_uri` when `prefix` is not found. + auto it = prefix_to_namespace_map_.find(prefix); + if (it != prefix_to_namespace_map_.end()) + adjusted_uri = it->value; + } else { adjusted_uri = default_namespace_uri_; + } } bool is_first_element = !saw_first_element_; |