summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/xml
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 15:28:34 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 13:54:51 +0000
commit2a19c63448c84c1805fb1a585c3651318bb86ca7 (patch)
treeeb17888e8531aa6ee5e85721bd553b832a7e5156 /chromium/third_party/blink/renderer/core/xml
parentb014812705fc80bff0a5c120dfcef88f349816dc (diff)
downloadqtwebengine-chromium-2a19c63448c84c1805fb1a585c3651318bb86ca7.tar.gz
BASELINE: Update Chromium to 69.0.3497.70
Change-Id: I2b7b56e4e7a8b26656930def0d4575dc32b900a0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/xml')
-rw-r--r--chromium/third_party/blink/renderer/core/xml/document_xml_tree_viewer.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/xml/document_xpath_evaluator.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/xml/dom_parser.cc29
-rw-r--r--chromium/third_party/blink/renderer/core/xml/dom_parser.h9
-rw-r--r--chromium/third_party/blink/renderer/core/xml/dom_parser.idl5
-rw-r--r--chromium/third_party/blink/renderer/core/xml/parser/shared_buffer_reader.cc20
-rw-r--r--chromium/third_party/blink/renderer/core/xml/parser/xml_document_parser.cc7
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xpath_evaluator.cc10
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xpath_expression.cc11
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xpath_parser.cc7
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xpath_result.cc5
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xslt_processor.cc1
-rw-r--r--chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc16
13 files changed, 83 insertions, 46 deletions
diff --git a/chromium/third_party/blink/renderer/core/xml/document_xml_tree_viewer.cc b/chromium/third_party/blink/renderer/core/xml/document_xml_tree_viewer.cc
index bb60c92233c..773262b5379 100644
--- a/chromium/third_party/blink/renderer/core/xml/document_xml_tree_viewer.cc
+++ b/chromium/third_party/blink/renderer/core/xml/document_xml_tree_viewer.cc
@@ -20,13 +20,11 @@ void TransformDocumentToXMLTreeView(Document& document) {
GetDataResourceAsASCIIString("DocumentXMLTreeViewer.js");
String css_string = GetDataResourceAsASCIIString("DocumentXMLTreeViewer.css");
- HeapVector<ScriptSourceCode> sources;
- sources.push_back(
- ScriptSourceCode(script_string, ScriptSourceLocationType::kInternal));
v8::HandleScope handle_scope(V8PerIsolateData::MainThreadIsolate());
document.GetFrame()->GetScriptController().ExecuteScriptInIsolatedWorld(
- IsolatedWorldId::kDocumentXMLTreeViewerWorldId, sources, nullptr);
+ IsolatedWorldId::kDocumentXMLTreeViewerWorldId,
+ ScriptSourceCode(script_string, ScriptSourceLocationType::kInternal));
Element* element = document.getElementById("xml-viewer-style");
if (element) {
diff --git a/chromium/third_party/blink/renderer/core/xml/document_xpath_evaluator.cc b/chromium/third_party/blink/renderer/core/xml/document_xpath_evaluator.cc
index 467bb0bc3e3..e1a1491106c 100644
--- a/chromium/third_party/blink/renderer/core/xml/document_xpath_evaluator.cc
+++ b/chromium/third_party/blink/renderer/core/xml/document_xpath_evaluator.cc
@@ -25,9 +25,10 @@
#include "third_party/blink/renderer/core/xml/document_xpath_evaluator.h"
-#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
+#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/xml/xpath_expression.h"
#include "third_party/blink/renderer/core/xml/xpath_result.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
diff --git a/chromium/third_party/blink/renderer/core/xml/dom_parser.cc b/chromium/third_party/blink/renderer/core/xml/dom_parser.cc
index 7189bb27b63..b322ad3ac99 100644
--- a/chromium/third_party/blink/renderer/core/xml/dom_parser.cc
+++ b/chromium/third_party/blink/renderer/core/xml/dom_parser.cc
@@ -18,14 +18,39 @@
*/
#include "third_party/blink/renderer/core/xml/dom_parser.h"
-
+#include "third_party/blink/renderer/bindings/core/v8/string_or_trusted_html.h"
+#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
+#include "third_party/blink/renderer/core/trustedtypes/trusted_html.h"
+#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
-Document* DOMParser::parseFromString(const String& str, const String& type) {
+Document* DOMParser::parseFromString(const StringOrTrustedHTML& stringOrHTML,
+ const String& type,
+ ExceptionState& exception_state) {
+ DCHECK(stringOrHTML.IsString() ||
+ RuntimeEnabledFeatures::TrustedDOMTypesEnabled());
+ DCHECK(!stringOrHTML.IsNull());
+ if (context_document_ && stringOrHTML.IsString() &&
+ context_document_->RequireTrustedTypes()) {
+ exception_state.ThrowTypeError(
+ "This document requires `TrustedHTML` assignment.");
+ return nullptr;
+ }
+
+ String valueString = stringOrHTML.IsString()
+ ? stringOrHTML.GetAsString()
+ : stringOrHTML.GetAsTrustedHTML()->toString();
+
+ return parseFromStringInternal(valueString, type);
+}
+
+Document* DOMParser::parseFromStringInternal(const String& str,
+ const String& type) {
Document* doc = DOMImplementation::createDocument(
type, DocumentInit::Create().WithContextDocument(context_document_),
false);
diff --git a/chromium/third_party/blink/renderer/core/xml/dom_parser.h b/chromium/third_party/blink/renderer/core/xml/dom_parser.h
index cea414f96b5..868e1f9b4ec 100644
--- a/chromium/third_party/blink/renderer/core/xml/dom_parser.h
+++ b/chromium/third_party/blink/renderer/core/xml/dom_parser.h
@@ -27,6 +27,8 @@
namespace blink {
class Document;
+class StringOrTrustedHTML;
+class ExceptionState;
class DOMParser final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
@@ -35,12 +37,15 @@ class DOMParser final : public ScriptWrappable {
static DOMParser* Create(Document& document) {
return new DOMParser(document);
}
-
- Document* parseFromString(const String&, const String& type);
+ Document* parseFromString(const StringOrTrustedHTML&,
+ const String& type,
+ ExceptionState& exception_state);
+ Document* parseFromString(const StringOrTrustedHTML&, const String& type);
void Trace(blink::Visitor*) override;
private:
+ Document* parseFromStringInternal(const String&, const String& type);
explicit DOMParser(Document&);
WeakMember<Document> context_document_;
diff --git a/chromium/third_party/blink/renderer/core/xml/dom_parser.idl b/chromium/third_party/blink/renderer/core/xml/dom_parser.idl
index 110d1ee1e58..b478df5d8e8 100644
--- a/chromium/third_party/blink/renderer/core/xml/dom_parser.idl
+++ b/chromium/third_party/blink/renderer/core/xml/dom_parser.idl
@@ -18,6 +18,9 @@
*/
// https://w3c.github.io/DOM-Parsing/#the-domparser-interface
+// The `HTMLString` reference below is from Trusted Types:
+// https://github.com/WICG/trusted-types/, which is still WIP.
+// https://crbug.com/739170.
enum SupportedType {
"text/html",
@@ -32,5 +35,5 @@ enum SupportedType {
ConstructorCallWith=Document,
Exposed=Window
] interface DOMParser {
- [NewObject] Document parseFromString(DOMString str, SupportedType type);
+ [NewObject, RaisesException] Document parseFromString(HTMLString str, SupportedType type);
};
diff --git a/chromium/third_party/blink/renderer/core/xml/parser/shared_buffer_reader.cc b/chromium/third_party/blink/renderer/core/xml/parser/shared_buffer_reader.cc
index 36f485bbaab..e9e9477a097 100644
--- a/chromium/third_party/blink/renderer/core/xml/parser/shared_buffer_reader.cc
+++ b/chromium/third_party/blink/renderer/core/xml/parser/shared_buffer_reader.cc
@@ -48,21 +48,19 @@ int SharedBufferReader::ReadData(char* output_buffer, int asked_to_read) {
return 0;
size_t bytes_copied = 0;
- size_t bytes_left = buffer_->size() - current_offset_;
- size_t len_to_copy = std::min(SafeCast<size_t>(asked_to_read), bytes_left);
-
- while (bytes_copied < len_to_copy) {
- const char* data;
- size_t segment_size = buffer_->GetSomeData(data, current_offset_);
- if (!segment_size)
+ size_t len_to_copy = std::min(SafeCast<size_t>(asked_to_read),
+ buffer_->size() - current_offset_);
+ for (auto it = buffer_->GetIteratorAt(current_offset_); it != buffer_->cend();
+ ++it) {
+ if (bytes_copied >= len_to_copy)
break;
+ size_t to_be_written = std::min(it->size(), len_to_copy - bytes_copied);
- segment_size = std::min(segment_size, len_to_copy - bytes_copied);
- memcpy(output_buffer + bytes_copied, data, segment_size);
- bytes_copied += segment_size;
- current_offset_ += segment_size;
+ memcpy(output_buffer + bytes_copied, it->data(), to_be_written);
+ bytes_copied += to_be_written;
}
+ current_offset_ += bytes_copied;
return SafeCast<int>(bytes_copied);
}
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 9744de383d9..d0539f61e4b 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
@@ -28,6 +28,10 @@
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
+#include <libxml/xmlversion.h>
+#if defined(LIBXML_CATALOG_ENABLED)
+#include <libxml/catalog.h>
+#endif
#include <libxslt/xslt.h>
#include <memory>
@@ -648,6 +652,9 @@ static void InitializeLibXMLIfNecessary() {
if (did_init)
return;
+#if defined(LIBXML_CATALOG_ENABLED)
+ xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE);
+#endif
xmlInitParser();
xmlRegisterInputCallbacks(MatchFunc, OpenFunc, ReadFunc, CloseFunc);
xmlRegisterOutputCallbacks(MatchFunc, OpenFunc, WriteFunc, CloseFunc);
diff --git a/chromium/third_party/blink/renderer/core/xml/xpath_evaluator.cc b/chromium/third_party/blink/renderer/core/xml/xpath_evaluator.cc
index 280c034fa36..7aff10329b3 100644
--- a/chromium/third_party/blink/renderer/core/xml/xpath_evaluator.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xpath_evaluator.cc
@@ -26,13 +26,13 @@
#include "third_party/blink/renderer/core/xml/xpath_evaluator.h"
-#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
-#include "third_party/blink/renderer/core/dom/exception_code.h"
+#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/xml/native_xpath_ns_resolver.h"
#include "third_party/blink/renderer/core/xml/xpath_expression.h"
#include "third_party/blink/renderer/core/xml/xpath_result.h"
#include "third_party/blink/renderer/core/xml/xpath_util.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
@@ -58,9 +58,9 @@ XPathResult* XPathEvaluator::evaluate(const String& expression,
ExceptionState& exception_state) {
if (!IsValidContextNode(context_node)) {
exception_state.ThrowDOMException(
- kNotSupportedError, "The node provided is '" +
- context_node->nodeName() +
- "', which is not a valid context node type.");
+ DOMExceptionCode::kNotSupportedError,
+ "The node provided is '" + context_node->nodeName() +
+ "', which is not a valid context node type.");
return nullptr;
}
diff --git a/chromium/third_party/blink/renderer/core/xml/xpath_expression.cc b/chromium/third_party/blink/renderer/core/xml/xpath_expression.cc
index 68054d6e431..7476499914a 100644
--- a/chromium/third_party/blink/renderer/core/xml/xpath_expression.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xpath_expression.cc
@@ -26,13 +26,12 @@
#include "third_party/blink/renderer/core/xml/xpath_expression.h"
-#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
-#include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/core/xml/xpath_expression_node.h"
#include "third_party/blink/renderer/core/xml/xpath_ns_resolver.h"
#include "third_party/blink/renderer/core/xml/xpath_parser.h"
#include "third_party/blink/renderer/core/xml/xpath_result.h"
#include "third_party/blink/renderer/core/xml/xpath_util.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
@@ -67,9 +66,9 @@ XPathResult* XPathExpression::evaluate(Node* context_node,
ExceptionState& exception_state) {
if (!IsValidContextNode(context_node)) {
exception_state.ThrowDOMException(
- kNotSupportedError, "The node provided is '" +
- context_node->nodeName() +
- "', which is not a valid context node type.");
+ DOMExceptionCode::kNotSupportedError,
+ "The node provided is '" + context_node->nodeName() +
+ "', which is not a valid context node type.");
return nullptr;
}
@@ -81,7 +80,7 @@ XPathResult* XPathExpression::evaluate(Node* context_node,
// It is not specified what to do if type conversion fails while evaluating
// an expression.
exception_state.ThrowDOMException(
- kSyntaxError,
+ DOMExceptionCode::kSyntaxError,
"Type conversion failed while evaluating the expression.");
return nullptr;
}
diff --git a/chromium/third_party/blink/renderer/core/xml/xpath_parser.cc b/chromium/third_party/blink/renderer/core/xml/xpath_parser.cc
index ac7baffc52c..12ed5132ae3 100644
--- a/chromium/third_party/blink/renderer/core/xml/xpath_parser.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xpath_parser.cc
@@ -28,12 +28,11 @@
#include "third_party/blink/renderer/core/xml/xpath_parser.h"
#include "base/memory/ptr_util.h"
-#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
-#include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/core/xml/xpath_evaluator.h"
#include "third_party/blink/renderer/core/xml/xpath_ns_resolver.h"
#include "third_party/blink/renderer/core/xml/xpath_path.h"
#include "third_party/blink/renderer/core/xpath_grammar.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
@@ -490,11 +489,11 @@ Expression* Parser::ParseStatement(const String& statement,
if (got_namespace_error_)
exception_state.ThrowDOMException(
- kNamespaceError,
+ DOMExceptionCode::kNamespaceError,
"The string '" + statement + "' contains unresolvable namespaces.");
else
exception_state.ThrowDOMException(
- kSyntaxError,
+ DOMExceptionCode::kSyntaxError,
"The string '" + statement + "' is not a valid XPath expression.");
return nullptr;
}
diff --git a/chromium/third_party/blink/renderer/core/xml/xpath_result.cc b/chromium/third_party/blink/renderer/core/xml/xpath_result.cc
index 96cd090cc1b..60da3f148e1 100644
--- a/chromium/third_party/blink/renderer/core/xml/xpath_result.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xpath_result.cc
@@ -26,11 +26,10 @@
#include "third_party/blink/renderer/core/xml/xpath_result.h"
-#include "third_party/blink/renderer/bindings/core/v8/exception_state.h"
#include "third_party/blink/renderer/core/dom/document.h"
-#include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/core/xml/xpath_evaluator.h"
#include "third_party/blink/renderer/core/xml/xpath_expression_node.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
@@ -188,7 +187,7 @@ Node* XPathResult::iterateNext(ExceptionState& exception_state) {
if (invalidIteratorState()) {
exception_state.ThrowDOMException(
- kInvalidStateError,
+ DOMExceptionCode::kInvalidStateError,
"The document has mutated since the result was returned.");
return nullptr;
}
diff --git a/chromium/third_party/blink/renderer/core/xml/xslt_processor.cc b/chromium/third_party/blink/renderer/core/xml/xslt_processor.cc
index 9e74930b253..b59f7fc0cff 100644
--- a/chromium/third_party/blink/renderer/core/xml/xslt_processor.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xslt_processor.cc
@@ -24,6 +24,7 @@
#include "third_party/blink/renderer/core/dom/document_encoding_data.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
+#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
diff --git a/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc b/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc
index 1605256724d..bb879481ed5 100644
--- a/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc
+++ b/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc
@@ -26,6 +26,7 @@
#include <libxslt/security.h>
#include <libxslt/variables.h>
#include <libxslt/xsltutils.h>
+#include "base/numerics/checked_math.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/transform_source.h"
@@ -134,12 +135,13 @@ static xmlDocPtr DocLoaderFunc(const xmlChar* uri,
xmlParserCtxtPtr ctx = xmlCreatePushParserCtxt(
nullptr, nullptr, nullptr, 0, reinterpret_cast<const char*>(uri));
if (ctx && !xmlCtxtUseOptions(ctx, options)) {
- data->ForEachSegment([&data, &ctx](const char* segment,
- size_t segment_size,
- size_t segment_offset) -> bool {
- bool final_chunk = segment_offset + segment_size == data->size();
- return !xmlParseChunk(ctx, segment, segment_size, final_chunk);
- });
+ size_t offset = 0;
+ for (const auto& span : *data) {
+ bool final_chunk = offset + span.size() == data->size();
+ if (!xmlParseChunk(ctx, span.data(), span.size(), final_chunk))
+ break;
+ offset += span.size();
+ }
if (ctx->wellFormed)
doc = ctx->myDoc;
@@ -233,7 +235,7 @@ static const char** XsltParamArrayFromParameterMap(
if (parameters.IsEmpty())
return nullptr;
- WTF::CheckedSizeT size = parameters.size();
+ base::CheckedNumeric<size_t> size = parameters.size();
size *= 2;
++size;
size *= sizeof(char*);