#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/xml/xslt_processor.h"
#include <libxslt/imports.h>
#include <libxslt/security.h>
#include <libxslt/variables.h>
#include <libxslt/xsltutils.h>
#include "base/numerics/checked_math.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/transform_source.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/frame/frame_console.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/xml/parser/xml_document_parser.h"
#include "third_party/blink/renderer/core/xml/parser/xml_document_parser_scope.h"
#include "third_party/blink/renderer/core/xml/xsl_style_sheet.h"
#include "third_party/blink/renderer/core/xml/xslt_extensions.h"
#include "third_party/blink/renderer/core/xml/xslt_unicode_sort.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_initiator_type_names.h"
#include "third_party/blink/renderer/platform/loader/fetch/raw_resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_error.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/allocator/partitions.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/utf8.h"
namespace {
constexpr int kDoubleXsltMaxVars = …;
}
namespace blink {
void XSLTProcessor::GenericErrorFunc(void*, const char*, ...) { … }
void XSLTProcessor::ParseErrorFunc(void* user_data, const xmlError* error) { … }
static XSLTProcessor* g_global_processor = …;
static ResourceFetcher* g_global_resource_fetcher = …;
static xmlDocPtr DocLoaderFunc(const xmlChar* uri,
xmlDictPtr,
int options,
void* ctxt,
xsltLoadType type) { … }
static inline void SetXSLTLoadCallBack(xsltDocLoaderFunc func,
XSLTProcessor* processor,
ResourceFetcher* fetcher) { … }
static int WriteToStringBuilder(void* context, const char* buffer, int len) { … }
static bool SaveResultToString(xmlDocPtr result_doc,
xsltStylesheetPtr sheet,
String& result_string) { … }
static char* AllocateParameterArray(const char* data) { … }
static const char** XsltParamArrayFromParameterMap(
XSLTProcessor::ParameterMap& parameters) { … }
static void FreeXsltParamArray(const char** params) { … }
static xsltStylesheetPtr XsltStylesheetPointer(
Document* document,
Member<XSLStyleSheet>& cached_stylesheet,
Node* stylesheet_root_node) { … }
static inline xmlDocPtr XmlDocPtrFromNode(Node* source_node,
bool& should_delete) { … }
static inline String ResultMIMEType(xmlDocPtr result_doc,
xsltStylesheetPtr sheet) { … }
bool XSLTProcessor::TransformToString(Node* source_node,
String& mime_type,
String& result_string,
String& result_encoding) { … }
}