mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-08-15 12:17:11 +02:00
Update libraries and make it build on windows.
Still gets some warnings because compilers have changed. But should work.
This commit is contained in:
+89
-15
@@ -51,8 +51,8 @@ AbstractContainerNode::~AbstractContainerNode()
|
||||
{
|
||||
AbstractNode* pDelNode = pChild;
|
||||
pChild = pChild->_pNext;
|
||||
pDelNode->_pNext = 0;
|
||||
pDelNode->_pParent = 0;
|
||||
pDelNode->_pNext = nullptr;
|
||||
pDelNode->_pParent = nullptr;
|
||||
pDelNode->release();
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,8 @@ Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild)
|
||||
if (this == newChild)
|
||||
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
|
||||
|
||||
AbstractNode* pFirst = 0;
|
||||
AbstractNode* pLast = 0;
|
||||
AbstractNode* pFirst = nullptr;
|
||||
AbstractNode* pLast = nullptr;
|
||||
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
|
||||
{
|
||||
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
|
||||
@@ -105,7 +105,7 @@ Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild)
|
||||
}
|
||||
pLast->_pParent = this;
|
||||
}
|
||||
pFrag->_pFirstChild = 0;
|
||||
pFrag->_pFirstChild = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,6 +151,80 @@ Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Node* AbstractContainerNode::insertAfterNP(Node* newChild, Node* refChild)
|
||||
{
|
||||
poco_check_ptr (newChild);
|
||||
|
||||
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pOwner && static_cast<AbstractNode*>(newChild)->_pOwner != this)
|
||||
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
|
||||
if (refChild && static_cast<AbstractNode*>(refChild)->_pParent != this)
|
||||
throw DOMException(DOMException::NOT_FOUND_ERR);
|
||||
if (newChild == refChild)
|
||||
return nullptr;
|
||||
if (this == newChild)
|
||||
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
|
||||
|
||||
AbstractNode* pFirst = nullptr;
|
||||
AbstractNode* pLast = nullptr;
|
||||
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
|
||||
{
|
||||
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
|
||||
pFirst = pFrag->_pFirstChild;
|
||||
pLast = pFirst;
|
||||
if (pFirst)
|
||||
{
|
||||
while (pLast->_pNext)
|
||||
{
|
||||
pLast->_pParent = this;
|
||||
pLast = pLast->_pNext;
|
||||
}
|
||||
pLast->_pParent = this;
|
||||
}
|
||||
pFrag->_pFirstChild = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChild->duplicate();
|
||||
AbstractContainerNode* pParent = static_cast<AbstractNode*>(newChild)->_pParent;
|
||||
if (pParent) pParent->removeChild(newChild);
|
||||
pFirst = static_cast<AbstractNode*>(newChild);
|
||||
pLast = pFirst;
|
||||
pFirst->_pParent = this;
|
||||
}
|
||||
if (_pFirstChild && pFirst)
|
||||
{
|
||||
AbstractNode* pCur = _pFirstChild;
|
||||
while (pCur && pCur != refChild)
|
||||
{
|
||||
pCur = pCur->_pNext;
|
||||
}
|
||||
if (pCur)
|
||||
{
|
||||
pLast->_pNext = pCur->_pNext;
|
||||
pCur->_pNext = pFirst;
|
||||
}
|
||||
else throw DOMException(DOMException::NOT_FOUND_ERR);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pFirstChild = pFirst;
|
||||
}
|
||||
|
||||
if (events())
|
||||
{
|
||||
while (pFirst && pFirst != pLast->_pNext)
|
||||
{
|
||||
pFirst->dispatchNodeInserted();
|
||||
pFirst->dispatchNodeInsertedIntoDocument();
|
||||
pFirst = pFirst->_pNext;
|
||||
}
|
||||
dispatchSubtreeModified();
|
||||
}
|
||||
return newChild;
|
||||
}
|
||||
|
||||
|
||||
Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild)
|
||||
{
|
||||
poco_check_ptr (newChild);
|
||||
@@ -185,8 +259,8 @@ Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild)
|
||||
}
|
||||
static_cast<AbstractNode*>(newChild)->_pNext = static_cast<AbstractNode*>(oldChild)->_pNext;
|
||||
static_cast<AbstractNode*>(newChild)->_pParent = this;
|
||||
_pFirstChild->_pNext = 0;
|
||||
_pFirstChild->_pParent = 0;
|
||||
_pFirstChild->_pNext = nullptr;
|
||||
_pFirstChild->_pParent = nullptr;
|
||||
_pFirstChild = static_cast<AbstractNode*>(newChild);
|
||||
if (doEvents)
|
||||
{
|
||||
@@ -209,8 +283,8 @@ Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild)
|
||||
}
|
||||
static_cast<AbstractNode*>(newChild)->_pNext = static_cast<AbstractNode*>(oldChild)->_pNext;
|
||||
static_cast<AbstractNode*>(newChild)->_pParent = this;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = nullptr;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = nullptr;
|
||||
pCur->_pNext = static_cast<AbstractNode*>(newChild);
|
||||
if (doEvents)
|
||||
{
|
||||
@@ -241,8 +315,8 @@ Node* AbstractContainerNode::removeChild(Node* oldChild)
|
||||
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemovedFromDocument();
|
||||
}
|
||||
_pFirstChild = _pFirstChild->_pNext;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = nullptr;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -256,8 +330,8 @@ Node* AbstractContainerNode::removeChild(Node* oldChild)
|
||||
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemovedFromDocument();
|
||||
}
|
||||
pCur->_pNext = pCur->_pNext->_pNext;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
|
||||
static_cast<AbstractNode*>(oldChild)->_pNext = nullptr;
|
||||
static_cast<AbstractNode*>(oldChild)->_pParent = nullptr;
|
||||
}
|
||||
else throw DOMException(DOMException::NOT_FOUND_ERR);
|
||||
}
|
||||
@@ -299,7 +373,7 @@ void AbstractContainerNode::dispatchNodeInsertedIntoDocument()
|
||||
|
||||
bool AbstractContainerNode::hasChildNodes() const
|
||||
{
|
||||
return _pFirstChild != 0;
|
||||
return _pFirstChild != nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -442,7 +516,7 @@ const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const
|
||||
while (it != end && *it != '/' && *it != '[') key += *it++;
|
||||
|
||||
XMLString::const_iterator itStart(it);
|
||||
const Node* pFound = 0;
|
||||
const Node* pFound = nullptr;
|
||||
const Node* pElem = findElement(key, pNode->firstChild(), pNSMap);
|
||||
while (!pFound && pElem)
|
||||
{
|
||||
|
||||
Vendored
+6
@@ -144,6 +144,12 @@ Node* AbstractNode::insertBefore(Node* newChild, Node* refChild)
|
||||
}
|
||||
|
||||
|
||||
Node* AbstractNode::insertAfterNP(Node* newChild, Node* refChild)
|
||||
{
|
||||
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
|
||||
|
||||
Node* AbstractNode::replaceChild(Node* newChild, Node* oldChild)
|
||||
{
|
||||
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
|
||||
|
||||
Vendored
+21
-13
@@ -28,6 +28,7 @@
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/SAX/XMLReader.h"
|
||||
#include "Poco/SAX/AttributesImpl.h"
|
||||
#include "Poco/XML/XMLException.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -37,14 +38,16 @@ namespace XML {
|
||||
const XMLString DOMBuilder::EMPTY_STRING;
|
||||
|
||||
|
||||
DOMBuilder::DOMBuilder(XMLReader& xmlReader, NamePool* pNamePool):
|
||||
DOMBuilder::DOMBuilder(XMLReader& xmlReader, NamePool* pNamePool, std::size_t maxDepth):
|
||||
_xmlReader(xmlReader),
|
||||
_pNamePool(pNamePool),
|
||||
_maxDepth(maxDepth),
|
||||
_pDocument(0),
|
||||
_pParent(0),
|
||||
_pPrevious(0),
|
||||
_inCDATA(false),
|
||||
_namespaces(true)
|
||||
_namespaces(true),
|
||||
_depth(0)
|
||||
{
|
||||
_xmlReader.setContentHandler(this);
|
||||
_xmlReader.setDTDHandler(this);
|
||||
@@ -71,9 +74,9 @@ Document* DOMBuilder::parse(const XMLString& uri)
|
||||
catch (...)
|
||||
{
|
||||
_pDocument->release();
|
||||
_pDocument = 0;
|
||||
_pParent = 0;
|
||||
_pPrevious = 0;
|
||||
_pDocument = nullptr;
|
||||
_pParent = nullptr;
|
||||
_pPrevious = nullptr;
|
||||
throw;
|
||||
}
|
||||
_pDocument->resumeEvents();
|
||||
@@ -93,9 +96,9 @@ Document* DOMBuilder::parse(InputSource* pInputSource)
|
||||
catch (...)
|
||||
{
|
||||
_pDocument->release();
|
||||
_pDocument = 0;
|
||||
_pParent = 0;
|
||||
_pPrevious = 0;
|
||||
_pDocument = nullptr;
|
||||
_pParent = nullptr;
|
||||
_pPrevious = nullptr;
|
||||
throw;
|
||||
}
|
||||
_pDocument->resumeEvents();
|
||||
@@ -115,9 +118,9 @@ Document* DOMBuilder::parseMemoryNP(const char* xml, std::size_t size)
|
||||
catch (...)
|
||||
{
|
||||
_pDocument->release();
|
||||
_pDocument = 0;
|
||||
_pParent = 0;
|
||||
_pPrevious = 0;
|
||||
_pDocument = nullptr;
|
||||
_pParent = nullptr;
|
||||
_pPrevious = nullptr;
|
||||
throw;
|
||||
}
|
||||
_pDocument->resumeEvents();
|
||||
@@ -130,7 +133,7 @@ void DOMBuilder::setupParse()
|
||||
{
|
||||
_pDocument = new Document(_pNamePool);
|
||||
_pParent = _pDocument;
|
||||
_pPrevious = 0;
|
||||
_pPrevious = nullptr;
|
||||
_inCDATA = false;
|
||||
_namespaces = _xmlReader.getFeature(XMLReader::FEATURE_NAMESPACES);
|
||||
}
|
||||
@@ -188,10 +191,13 @@ void DOMBuilder::endDocument()
|
||||
|
||||
void DOMBuilder::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
|
||||
{
|
||||
++_depth;
|
||||
if (_maxDepth > 0 && _depth > _maxDepth) throw XMLException("Maximum element depth exceeded");
|
||||
|
||||
AutoPtr<Element> pElem = _namespaces ? _pDocument->createElementNS(uri, qname.empty() ? localName : qname) : _pDocument->createElement(qname);
|
||||
|
||||
const AttributesImpl& attrs = dynamic_cast<const AttributesImpl&>(attributes);
|
||||
Attr* pPrevAttr = 0;
|
||||
Attr* pPrevAttr = nullptr;
|
||||
for (const auto& attr: attrs)
|
||||
{
|
||||
AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, attr.namespaceURI, attr.localName, attr.qname, attr.value, attr.specified);
|
||||
@@ -204,6 +210,8 @@ void DOMBuilder::startElement(const XMLString& uri, const XMLString& localName,
|
||||
|
||||
void DOMBuilder::endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname)
|
||||
{
|
||||
--_depth;
|
||||
|
||||
_pPrevious = _pParent;
|
||||
_pParent = static_cast<AbstractContainerNode*>(_pParent->parentNode());
|
||||
}
|
||||
|
||||
+2
-8
@@ -17,7 +17,6 @@
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/SingletonHolder.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -71,15 +70,10 @@ Document* DOMImplementation::createDocument(const XMLString& namespaceURI, const
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
static Poco::SingletonHolder<DOMImplementation> sh;
|
||||
}
|
||||
|
||||
|
||||
const DOMImplementation& DOMImplementation::instance()
|
||||
{
|
||||
return *sh.get();
|
||||
static DOMImplementation di;
|
||||
return di;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+20
-10
@@ -28,8 +28,7 @@ const XMLString DOMParser::FEATURE_FILTER_WHITESPACE = toXMLString("http://www.a
|
||||
|
||||
|
||||
DOMParser::DOMParser(NamePool* pNamePool):
|
||||
_pNamePool(pNamePool),
|
||||
_filterWhitespace(false)
|
||||
_pNamePool(pNamePool)
|
||||
{
|
||||
if (_pNamePool) _pNamePool->duplicate();
|
||||
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
|
||||
@@ -38,8 +37,7 @@ DOMParser::DOMParser(NamePool* pNamePool):
|
||||
|
||||
|
||||
DOMParser::DOMParser(unsigned long namePoolSize):
|
||||
_pNamePool(new NamePool(namePoolSize)),
|
||||
_filterWhitespace(false)
|
||||
_pNamePool(new NamePool(namePoolSize))
|
||||
{
|
||||
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
|
||||
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
|
||||
@@ -93,12 +91,12 @@ Document* DOMParser::parse(const XMLString& uri)
|
||||
if (_filterWhitespace)
|
||||
{
|
||||
WhitespaceFilter filter(&_saxParser);
|
||||
DOMBuilder builder(filter, _pNamePool);
|
||||
DOMBuilder builder(filter, _pNamePool, _maxElementDepth);
|
||||
return builder.parse(uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
DOMBuilder builder(_saxParser, _pNamePool);
|
||||
DOMBuilder builder(_saxParser, _pNamePool, _maxElementDepth);
|
||||
return builder.parse(uri);
|
||||
}
|
||||
}
|
||||
@@ -109,12 +107,12 @@ Document* DOMParser::parse(InputSource* pInputSource)
|
||||
if (_filterWhitespace)
|
||||
{
|
||||
WhitespaceFilter filter(&_saxParser);
|
||||
DOMBuilder builder(filter, _pNamePool);
|
||||
DOMBuilder builder(filter, _pNamePool, _maxElementDepth);
|
||||
return builder.parse(pInputSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
DOMBuilder builder(_saxParser, _pNamePool);
|
||||
DOMBuilder builder(_saxParser, _pNamePool, _maxElementDepth);
|
||||
return builder.parse(pInputSource);
|
||||
}
|
||||
}
|
||||
@@ -131,12 +129,12 @@ Document* DOMParser::parseMemory(const char* xml, std::size_t size)
|
||||
if (_filterWhitespace)
|
||||
{
|
||||
WhitespaceFilter filter(&_saxParser);
|
||||
DOMBuilder builder(filter, _pNamePool);
|
||||
DOMBuilder builder(filter, _pNamePool, _maxElementDepth);
|
||||
return builder.parseMemoryNP(xml, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
DOMBuilder builder(_saxParser, _pNamePool);
|
||||
DOMBuilder builder(_saxParser, _pNamePool, _maxElementDepth);
|
||||
return builder.parseMemoryNP(xml, size);
|
||||
}
|
||||
}
|
||||
@@ -154,4 +152,16 @@ void DOMParser::setEntityResolver(EntityResolver* pEntityResolver)
|
||||
}
|
||||
|
||||
|
||||
void DOMParser::setMaxElementDepth(std::size_t limit)
|
||||
{
|
||||
_maxElementDepth = limit;
|
||||
}
|
||||
|
||||
|
||||
std::size_t DOMParser::getMaxElementDepth() const
|
||||
{
|
||||
return _maxElementDepth;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
Vendored
+5
-5
@@ -143,8 +143,8 @@ Attr* Element::removeAttributeNode(Attr* oldAttr)
|
||||
else throw DOMException(DOMException::NOT_FOUND_ERR);
|
||||
}
|
||||
else _pFirstAttr = static_cast<Attr*>(_pFirstAttr->_pNext);
|
||||
oldAttr->_pNext = 0;
|
||||
oldAttr->_pParent = 0;
|
||||
oldAttr->_pNext = nullptr;
|
||||
oldAttr->_pParent = nullptr;
|
||||
oldAttr->autoRelease();
|
||||
|
||||
return oldAttr;
|
||||
@@ -298,13 +298,13 @@ Attr* Element::setAttributeNodeNS(Attr* newAttr)
|
||||
|
||||
bool Element::hasAttribute(const XMLString& name) const
|
||||
{
|
||||
return getAttributeNode(name) != 0;
|
||||
return getAttributeNode(name) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
bool Element::hasAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const
|
||||
{
|
||||
return getAttributeNodeNS(namespaceURI, localName) != 0;
|
||||
return getAttributeNodeNS(namespaceURI, localName) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ const XMLString& Element::localName() const
|
||||
|
||||
bool Element::hasAttributes() const
|
||||
{
|
||||
return _pFirstAttr != 0;
|
||||
return _pFirstAttr != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ void EventDispatcher::removeEventListener(const XMLString& type, EventListener*
|
||||
{
|
||||
if (it->type == type && it->pListener == listener && it->useCapture == useCapture)
|
||||
{
|
||||
it->pListener = 0;
|
||||
it->pListener = nullptr;
|
||||
}
|
||||
if (!_inDispatch && !it->pListener)
|
||||
{
|
||||
|
||||
Vendored
+1
-1
@@ -60,7 +60,7 @@ void NodeAppender::appendChild(Node* newChild)
|
||||
pChild->_pParent = _pParent;
|
||||
pChild = pChild->_pNext;
|
||||
}
|
||||
pFrag->_pFirstChild = 0;
|
||||
pFrag->_pFirstChild = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Vendored
+3
-3
@@ -88,8 +88,8 @@ Node* NodeIterator::previousNode()
|
||||
|
||||
void NodeIterator::detach()
|
||||
{
|
||||
_pRoot = 0;
|
||||
_pCurrent = 0;
|
||||
_pRoot = nullptr;
|
||||
_pCurrent = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ Node* NodeIterator::previous() const
|
||||
Node* NodeIterator::last()
|
||||
{
|
||||
_pCurrent = _pRoot;
|
||||
Node* pLast = 0;
|
||||
Node* pLast = nullptr;
|
||||
while (_pCurrent)
|
||||
{
|
||||
pLast = _pCurrent;
|
||||
|
||||
Vendored
+4
-4
@@ -12,7 +12,7 @@
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/XML/ParserEngine.h"
|
||||
#include "ParserEngine.h"
|
||||
#include "Poco/XML/NamespaceStrategy.h"
|
||||
#include "Poco/XML/XMLException.h"
|
||||
#include "Poco/SAX/EntityResolver.h"
|
||||
@@ -748,8 +748,8 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con
|
||||
if (!context && !pThis->_externalParameterEntities) return XML_STATUS_ERROR;
|
||||
if (context && !pThis->_externalGeneralEntities) return XML_STATUS_ERROR;
|
||||
|
||||
InputSource* pInputSource = 0;
|
||||
EntityResolver* pEntityResolver = 0;
|
||||
InputSource* pInputSource = nullptr;
|
||||
EntityResolver* pEntityResolver = nullptr;
|
||||
EntityResolverImpl defaultResolver;
|
||||
|
||||
XMLString sysId(systemId);
|
||||
@@ -798,7 +798,7 @@ int ParserEngine::handleUnknownEncoding(void* encodingHandlerData, const XML_Cha
|
||||
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(encodingHandlerData);
|
||||
|
||||
XMLString encoding(name);
|
||||
TextEncoding* knownEncoding = 0;
|
||||
TextEncoding* knownEncoding = nullptr;
|
||||
|
||||
EncodingMap::const_iterator it = pThis->_encodings.find(encoding);
|
||||
if (it != pThis->_encodings.end())
|
||||
|
||||
Vendored
+384
@@ -0,0 +1,384 @@
|
||||
//
|
||||
// ParserEngine.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: ParserEngine
|
||||
//
|
||||
// Definition of the ParseEngine class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
|
||||
#ifndef XML_ParserEngine_INCLUDED
|
||||
#define XML_ParserEngine_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#if defined(POCO_UNBUNDLED)
|
||||
#include <expat.h>
|
||||
#else
|
||||
#include "expat.h"
|
||||
#endif
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/XMLStream.h"
|
||||
#include "Poco/SAX/Locator.h"
|
||||
#include "Poco/TextEncoding.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class InputSource;
|
||||
class EntityResolver;
|
||||
class DTDHandler;
|
||||
class DeclHandler;
|
||||
class ContentHandler;
|
||||
class LexicalHandler;
|
||||
class ErrorHandler;
|
||||
class NamespaceStrategy;
|
||||
class ContextLocator;
|
||||
|
||||
|
||||
class XML_API ParserEngine: public Locator
|
||||
/// This class provides an object-oriented, stream-based,
|
||||
/// low-level interface to the XML Parser Toolkit (expat).
|
||||
/// It is strongly recommended, that you use the
|
||||
/// SAX parser classes (which are based on this
|
||||
/// class) instead of this class, since they provide
|
||||
/// a standardized, higher-level interface to the parser.
|
||||
{
|
||||
public:
|
||||
ParserEngine();
|
||||
/// Creates the parser engine.
|
||||
|
||||
ParserEngine(const XMLString& encoding);
|
||||
/// Creates the parser engine and passes the encoding
|
||||
/// to the underlying parser.
|
||||
|
||||
~ParserEngine();
|
||||
/// Destroys the parser.
|
||||
|
||||
void setEncoding(const XMLString& encoding);
|
||||
/// Sets the encoding used by expat. The encoding must be
|
||||
/// set before parsing begins, otherwise it will be ignored.
|
||||
|
||||
const XMLString& getEncoding() const;
|
||||
/// Returns the encoding used by expat.
|
||||
|
||||
void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding);
|
||||
/// Adds an encoding to the parser.
|
||||
|
||||
void setNamespaceStrategy(NamespaceStrategy* pStrategy);
|
||||
/// Sets the NamespaceStrategy used by the parser.
|
||||
/// The parser takes ownership of the strategy object
|
||||
/// and deletes it when it's no longer needed.
|
||||
/// The default is NoNamespacesStrategy.
|
||||
|
||||
NamespaceStrategy* getNamespaceStrategy() const;
|
||||
/// Returns the NamespaceStrategy currently in use.
|
||||
|
||||
void setExpandInternalEntities(bool flag = true);
|
||||
/// Enables/disables expansion of internal entities (enabled by
|
||||
/// default). If entity expansion is disabled, internal entities
|
||||
/// are reported via the default handler.
|
||||
/// Must be set before parsing begins, otherwise it will be
|
||||
/// ignored.
|
||||
|
||||
bool getExpandInternalEntities() const;
|
||||
/// Returns true if internal entities will be expanded automatically,
|
||||
/// which is the default.
|
||||
|
||||
void setExternalGeneralEntities(bool flag = true);
|
||||
/// Enable or disable processing of external general entities.
|
||||
|
||||
bool getExternalGeneralEntities() const;
|
||||
/// Returns true if external general entities will be processed; false otherwise.
|
||||
|
||||
void setExternalParameterEntities(bool flag = true);
|
||||
/// Enable or disable processing of external parameter entities.
|
||||
|
||||
bool getExternalParameterEntities() const;
|
||||
/// Returns true if external parameter entities will be processed; false otherwise.
|
||||
|
||||
void setEntityResolver(EntityResolver* pResolver);
|
||||
/// Allow an application to register an entity resolver.
|
||||
|
||||
EntityResolver* getEntityResolver() const;
|
||||
/// Return the current entity resolver.
|
||||
|
||||
void setDTDHandler(DTDHandler* pDTDHandler);
|
||||
/// Allow an application to register a DTD event handler.
|
||||
|
||||
DTDHandler* getDTDHandler() const;
|
||||
/// Return the current DTD handler.
|
||||
|
||||
void setDeclHandler(DeclHandler* pDeclHandler);
|
||||
/// Allow an application to register a DTD declarations event handler.
|
||||
|
||||
DeclHandler* getDeclHandler() const;
|
||||
/// Return the current DTD declarations handler.
|
||||
|
||||
void setContentHandler(ContentHandler* pContentHandler);
|
||||
/// Allow an application to register a content event handler.
|
||||
|
||||
ContentHandler* getContentHandler() const;
|
||||
/// Return the current content handler.
|
||||
|
||||
void setLexicalHandler(LexicalHandler* pLexicalHandler);
|
||||
/// Allow an application to register a lexical event handler.
|
||||
|
||||
LexicalHandler* getLexicalHandler() const;
|
||||
/// Return the current lexical handler.
|
||||
|
||||
void setErrorHandler(ErrorHandler* pErrorHandler);
|
||||
/// Allow an application to register an error event handler.
|
||||
|
||||
ErrorHandler* getErrorHandler() const;
|
||||
/// Return the current error handler.
|
||||
|
||||
void setEnablePartialReads(bool flag = true);
|
||||
/// Enable or disable partial reads from the input source.
|
||||
///
|
||||
/// This is useful for parsing XML from a socket stream for
|
||||
/// a protocol like XMPP, where basically single elements
|
||||
/// are read one at a time from the input source's stream, and
|
||||
/// following elements depend upon responses sent back to
|
||||
/// the peer.
|
||||
///
|
||||
/// Normally, the parser always reads blocks of PARSE_BUFFER_SIZE
|
||||
/// at a time, and blocks until a complete block has been read (or
|
||||
/// the end of the stream has been reached).
|
||||
/// This allows for efficient parsing of "complete" XML documents,
|
||||
/// but fails in a case such as XMPP, where only XML fragments
|
||||
/// are sent at a time.
|
||||
|
||||
bool getEnablePartialReads() const;
|
||||
/// Returns true if partial reads are enabled (see
|
||||
/// setEnablePartialReads()), false otherwise.
|
||||
|
||||
void setBillionLaughsAttackProtectionMaximumAmplification(float maximumAmplificationFactor);
|
||||
/// Sets the maximum tolerated amplification factor
|
||||
/// for protection against Billion Laughs Attacks.
|
||||
///
|
||||
/// The amplification factor is calculated as:
|
||||
/// amplification := (direct + indirect) / direct
|
||||
/// while parsing, whereas:
|
||||
/// - direct is the number of bytes read from the primary document in parsing and
|
||||
/// - indirect is the number of bytes added by expanding entities and reading of
|
||||
/// external DTD files, combined.
|
||||
///
|
||||
/// maximumAmplificationFactor must be non-NaN and greater than or equal to 1.0.
|
||||
///
|
||||
/// Requires an underlying Expat version >= 2.4.0.
|
||||
|
||||
void setBillionLaughsAttackProtectionActivationThreshold(Poco::UInt64 activationThresholdBytes);
|
||||
/// Sets number of output bytes (including amplification from entity expansion and reading DTD files)
|
||||
/// needed to activate protection against Billion Laughs Attacks.
|
||||
///
|
||||
/// Defaults to 8 MiB.
|
||||
///
|
||||
/// Requires an underlying Expat version >= 2.4.0.
|
||||
|
||||
void parse(InputSource* pInputSource);
|
||||
/// Parse an XML document from the given InputSource.
|
||||
|
||||
void parse(const char* pBuffer, std::size_t size);
|
||||
/// Parses an XML document from the given buffer.
|
||||
|
||||
// Locator
|
||||
XMLString getPublicId() const;
|
||||
/// Return the public identifier for the current document event.
|
||||
|
||||
XMLString getSystemId() const;
|
||||
/// Return the system identifier for the current document event.
|
||||
|
||||
int getLineNumber() const;
|
||||
/// Return the line number where the current document event ends.
|
||||
|
||||
int getColumnNumber() const;
|
||||
/// Return the column number where the current document event ends.
|
||||
|
||||
protected:
|
||||
void init();
|
||||
/// initializes expat
|
||||
|
||||
void parseByteInputStream(XMLByteInputStream& istr);
|
||||
/// Parses an entity from the given stream.
|
||||
|
||||
void parseCharInputStream(XMLCharInputStream& istr);
|
||||
/// Parses an entity from the given stream.
|
||||
|
||||
std::streamsize readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize);
|
||||
/// Reads at most bufferSize bytes from the given stream into the given buffer.
|
||||
|
||||
std::streamsize readChars(XMLCharInputStream& istr, XMLChar* pBuffer, std::streamsize bufferSize);
|
||||
/// Reads at most bufferSize chars from the given stream into the given buffer.
|
||||
|
||||
void handleError(int errorNo);
|
||||
/// Throws an XMLException with a message corresponding
|
||||
/// to the given Expat error code.
|
||||
|
||||
void parseExternal(XML_Parser extParser, InputSource* pInputSource);
|
||||
/// Parse an XML document from the given InputSource.
|
||||
|
||||
void parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr);
|
||||
/// Parses an external entity from the given stream, with a separate parser.
|
||||
|
||||
void parseExternalCharInputStream(XML_Parser extParser, XMLCharInputStream& istr);
|
||||
/// Parses an external entity from the given stream, with a separate parser.
|
||||
|
||||
void pushContext(XML_Parser parser, InputSource* pInputSource);
|
||||
/// Pushes a new entry to the context stack.
|
||||
|
||||
void popContext();
|
||||
/// Pops the top-most entry from the context stack.
|
||||
|
||||
void resetContext();
|
||||
/// Resets and clears the context stack.
|
||||
|
||||
const Locator& locator() const;
|
||||
/// Returns a locator denoting the current parse location.
|
||||
|
||||
// expat handler procedures
|
||||
static void handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts);
|
||||
static void handleEndElement(void* userData, const XML_Char* name);
|
||||
static void handleCharacterData(void* userData, const XML_Char* s, int len);
|
||||
static void handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data);
|
||||
static void handleDefault(void* userData, const XML_Char* s, int len);
|
||||
static void handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName);
|
||||
static void handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static int handleExternalEntityRef(XML_Parser parser, const XML_Char* openEntityNames, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static int handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info);
|
||||
static void handleComment(void* userData, const XML_Char* data);
|
||||
static void handleStartCdataSection(void* userData);
|
||||
static void handleEndCdataSection(void* userData);
|
||||
static void handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri);
|
||||
static void handleEndNamespaceDecl(void* userData, const XML_Char* prefix);
|
||||
static void handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset);
|
||||
static void handleEndDoctypeDecl(void* userData);
|
||||
static void handleEntityDecl(void *userData, const XML_Char *entityName, int isParamEntity, const XML_Char *value, int valueLength,
|
||||
const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName);
|
||||
static void handleExternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static void handleInternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength);
|
||||
static void handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity);
|
||||
|
||||
// encoding support
|
||||
static int convert(void *data, const char *s);
|
||||
|
||||
private:
|
||||
typedef std::map<XMLString, Poco::TextEncoding*> EncodingMap;
|
||||
typedef std::vector<ContextLocator*> ContextStack;
|
||||
|
||||
XML_Parser _parser;
|
||||
char* _pBuffer;
|
||||
bool _encodingSpecified;
|
||||
XMLString _encoding;
|
||||
bool _expandInternalEntities;
|
||||
bool _externalGeneralEntities;
|
||||
bool _externalParameterEntities;
|
||||
bool _enablePartialReads;
|
||||
NamespaceStrategy* _pNamespaceStrategy;
|
||||
EncodingMap _encodings;
|
||||
ContextStack _context;
|
||||
|
||||
EntityResolver* _pEntityResolver;
|
||||
DTDHandler* _pDTDHandler;
|
||||
DeclHandler* _pDeclHandler;
|
||||
ContentHandler* _pContentHandler;
|
||||
LexicalHandler* _pLexicalHandler;
|
||||
ErrorHandler* _pErrorHandler;
|
||||
|
||||
float _maximumAmplificationFactor;
|
||||
Poco::UInt64 _activationThresholdBytes;
|
||||
|
||||
static const int PARSE_BUFFER_SIZE;
|
||||
static const XMLString EMPTY_STRING;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const XMLString& ParserEngine::getEncoding() const
|
||||
{
|
||||
return _encoding;
|
||||
}
|
||||
|
||||
|
||||
inline NamespaceStrategy* ParserEngine::getNamespaceStrategy() const
|
||||
{
|
||||
return _pNamespaceStrategy;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExpandInternalEntities() const
|
||||
{
|
||||
return _expandInternalEntities;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExternalGeneralEntities() const
|
||||
{
|
||||
return _externalGeneralEntities;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExternalParameterEntities() const
|
||||
{
|
||||
return _externalParameterEntities;
|
||||
}
|
||||
|
||||
|
||||
inline EntityResolver* ParserEngine::getEntityResolver() const
|
||||
{
|
||||
return _pEntityResolver;
|
||||
}
|
||||
|
||||
|
||||
inline DTDHandler* ParserEngine::getDTDHandler() const
|
||||
{
|
||||
return _pDTDHandler;
|
||||
}
|
||||
|
||||
|
||||
inline DeclHandler* ParserEngine::getDeclHandler() const
|
||||
{
|
||||
return _pDeclHandler;
|
||||
}
|
||||
|
||||
|
||||
inline ContentHandler* ParserEngine::getContentHandler() const
|
||||
{
|
||||
return _pContentHandler;
|
||||
}
|
||||
|
||||
|
||||
inline LexicalHandler* ParserEngine::getLexicalHandler() const
|
||||
{
|
||||
return _pLexicalHandler;
|
||||
}
|
||||
|
||||
|
||||
inline ErrorHandler* ParserEngine::getErrorHandler() const
|
||||
{
|
||||
return _pErrorHandler;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getEnablePartialReads() const
|
||||
{
|
||||
return _enablePartialReads;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_ParserEngine_INCLUDED
|
||||
Vendored
+33
-30
@@ -18,6 +18,7 @@
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include "Poco/XML/NamespaceStrategy.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "ParserEngine.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -34,85 +35,87 @@ SAXParser::SAXParser():
|
||||
_namespaces(true),
|
||||
_namespacePrefixes(false)
|
||||
{
|
||||
_engine = new ParserEngine;
|
||||
}
|
||||
|
||||
|
||||
SAXParser::SAXParser(const XMLString& encoding):
|
||||
_engine(encoding),
|
||||
_namespaces(true),
|
||||
_namespacePrefixes(false)
|
||||
{
|
||||
_engine = new ParserEngine(encoding);
|
||||
}
|
||||
|
||||
|
||||
SAXParser::~SAXParser()
|
||||
{
|
||||
delete _engine;
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setEncoding(const XMLString& encoding)
|
||||
{
|
||||
_engine.setEncoding(encoding);
|
||||
_engine->setEncoding(encoding);
|
||||
}
|
||||
|
||||
|
||||
const XMLString& SAXParser::getEncoding() const
|
||||
{
|
||||
return _engine.getEncoding();
|
||||
return _engine->getEncoding();
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding)
|
||||
{
|
||||
_engine.addEncoding(name, pEncoding);
|
||||
_engine->addEncoding(name, pEncoding);
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setEntityResolver(EntityResolver* pResolver)
|
||||
{
|
||||
_engine.setEntityResolver(pResolver);
|
||||
_engine->setEntityResolver(pResolver);
|
||||
}
|
||||
|
||||
|
||||
EntityResolver* SAXParser::getEntityResolver() const
|
||||
{
|
||||
return _engine.getEntityResolver();
|
||||
return _engine->getEntityResolver();
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setDTDHandler(DTDHandler* pDTDHandler)
|
||||
{
|
||||
_engine.setDTDHandler(pDTDHandler);
|
||||
_engine->setDTDHandler(pDTDHandler);
|
||||
}
|
||||
|
||||
|
||||
DTDHandler* SAXParser::getDTDHandler() const
|
||||
{
|
||||
return _engine.getDTDHandler();
|
||||
return _engine->getDTDHandler();
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setContentHandler(ContentHandler* pContentHandler)
|
||||
{
|
||||
_engine.setContentHandler(pContentHandler);
|
||||
_engine->setContentHandler(pContentHandler);
|
||||
}
|
||||
|
||||
|
||||
ContentHandler* SAXParser::getContentHandler() const
|
||||
{
|
||||
return _engine.getContentHandler();
|
||||
return _engine->getContentHandler();
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setErrorHandler(ErrorHandler* pErrorHandler)
|
||||
{
|
||||
_engine.setErrorHandler(pErrorHandler);
|
||||
_engine->setErrorHandler(pErrorHandler);
|
||||
}
|
||||
|
||||
|
||||
ErrorHandler* SAXParser::getErrorHandler() const
|
||||
{
|
||||
return _engine.getErrorHandler();
|
||||
return _engine->getErrorHandler();
|
||||
}
|
||||
|
||||
|
||||
@@ -121,15 +124,15 @@ void SAXParser::setFeature(const XMLString& featureId, bool state)
|
||||
if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING)
|
||||
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION));
|
||||
else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES)
|
||||
_engine.setExternalGeneralEntities(state);
|
||||
_engine->setExternalGeneralEntities(state);
|
||||
else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES)
|
||||
_engine.setExternalParameterEntities(state);
|
||||
_engine->setExternalParameterEntities(state);
|
||||
else if (featureId == XMLReader::FEATURE_NAMESPACES)
|
||||
_namespaces = state;
|
||||
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
|
||||
_namespacePrefixes = state;
|
||||
else if (featureId == FEATURE_PARTIAL_READS)
|
||||
_engine.setEnablePartialReads(state);
|
||||
_engine->setEnablePartialReads(state);
|
||||
else throw SAXNotRecognizedException(fromXMLString(featureId));
|
||||
}
|
||||
|
||||
@@ -139,15 +142,15 @@ bool SAXParser::getFeature(const XMLString& featureId) const
|
||||
if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING)
|
||||
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION));
|
||||
else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES)
|
||||
return _engine.getExternalGeneralEntities();
|
||||
return _engine->getExternalGeneralEntities();
|
||||
else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES)
|
||||
return _engine.getExternalParameterEntities();
|
||||
return _engine->getExternalParameterEntities();
|
||||
else if (featureId == XMLReader::FEATURE_NAMESPACES)
|
||||
return _namespaces;
|
||||
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
|
||||
return _namespacePrefixes;
|
||||
else if (featureId == FEATURE_PARTIAL_READS)
|
||||
return _engine.getEnablePartialReads();
|
||||
return _engine->getEnablePartialReads();
|
||||
else throw SAXNotRecognizedException(fromXMLString(featureId));
|
||||
}
|
||||
|
||||
@@ -157,9 +160,9 @@ void SAXParser::setProperty(const XMLString& propertyId, const XMLString& value)
|
||||
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER || propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
|
||||
throw SAXNotSupportedException(std::string("property does not take a string value: ") + fromXMLString(propertyId));
|
||||
else if (propertyId == PROPERTY_BLA_MAXIMUM_AMPLIFICATION)
|
||||
_engine.setBillionLaughsAttackProtectionMaximumAmplification(static_cast<float>(Poco::NumberParser::parseFloat(value)));
|
||||
_engine->setBillionLaughsAttackProtectionMaximumAmplification(static_cast<float>(Poco::NumberParser::parseFloat(value)));
|
||||
else if (propertyId == PROPERTY_BLA_ACTIVATION_THRESHOLD)
|
||||
_engine.setBillionLaughsAttackProtectionActivationThreshold(Poco::NumberParser::parseUnsigned64(value));
|
||||
_engine->setBillionLaughsAttackProtectionActivationThreshold(Poco::NumberParser::parseUnsigned64(value));
|
||||
else
|
||||
throw SAXNotRecognizedException(fromXMLString(propertyId));
|
||||
}
|
||||
@@ -168,9 +171,9 @@ void SAXParser::setProperty(const XMLString& propertyId, const XMLString& value)
|
||||
void SAXParser::setProperty(const XMLString& propertyId, void* value)
|
||||
{
|
||||
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
|
||||
_engine.setDeclHandler(reinterpret_cast<DeclHandler*>(value));
|
||||
_engine->setDeclHandler(reinterpret_cast<DeclHandler*>(value));
|
||||
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
|
||||
_engine.setLexicalHandler(reinterpret_cast<LexicalHandler*>(value));
|
||||
_engine->setLexicalHandler(reinterpret_cast<LexicalHandler*>(value));
|
||||
else throw SAXNotRecognizedException(fromXMLString(propertyId));
|
||||
}
|
||||
|
||||
@@ -178,9 +181,9 @@ void SAXParser::setProperty(const XMLString& propertyId, void* value)
|
||||
void* SAXParser::getProperty(const XMLString& propertyId) const
|
||||
{
|
||||
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
|
||||
return _engine.getDeclHandler();
|
||||
return _engine->getDeclHandler();
|
||||
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
|
||||
return _engine.getLexicalHandler();
|
||||
return _engine->getLexicalHandler();
|
||||
else throw SAXNotSupportedException(fromXMLString(propertyId));
|
||||
}
|
||||
|
||||
@@ -190,7 +193,7 @@ void SAXParser::parse(InputSource* pInputSource)
|
||||
if (pInputSource->getByteStream() || pInputSource->getCharacterStream())
|
||||
{
|
||||
setupParse();
|
||||
_engine.parse(pInputSource);
|
||||
_engine->parse(pInputSource);
|
||||
}
|
||||
else parse(pInputSource->getSystemId());
|
||||
}
|
||||
@@ -205,7 +208,7 @@ void SAXParser::parse(const XMLString& systemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_engine.parse(pInputSource);
|
||||
_engine->parse(pInputSource);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -227,18 +230,18 @@ void SAXParser::parseString(const std::string& xml)
|
||||
void SAXParser::parseMemoryNP(const char* xml, std::size_t size)
|
||||
{
|
||||
setupParse();
|
||||
_engine.parse(xml, size);
|
||||
_engine->parse(xml, size);
|
||||
}
|
||||
|
||||
|
||||
void SAXParser::setupParse()
|
||||
{
|
||||
if (_namespaces && !_namespacePrefixes)
|
||||
_engine.setNamespaceStrategy(new NoNamespacePrefixesStrategy);
|
||||
_engine->setNamespaceStrategy(new NoNamespacePrefixesStrategy);
|
||||
else if (_namespaces && _namespacePrefixes)
|
||||
_engine.setNamespaceStrategy(new NamespacePrefixesStrategy);
|
||||
_engine->setNamespaceStrategy(new NamespacePrefixesStrategy);
|
||||
else
|
||||
_engine.setNamespaceStrategy(new NoNamespacesStrategy);
|
||||
_engine->setNamespaceStrategy(new NoNamespacesStrategy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -73,7 +73,7 @@ Node* TreeWalker::parentNode()
|
||||
if (pParent && accept(pParent) == NodeFilter::FILTER_ACCEPT)
|
||||
_pCurrent = pParent;
|
||||
else
|
||||
pParent = 0;
|
||||
pParent = nullptr;
|
||||
return pParent;
|
||||
}
|
||||
|
||||
|
||||
+14
-8
@@ -16,6 +16,12 @@
|
||||
|
||||
|
||||
#include "Poco/XML/XMLStreamParser.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#if defined(POCO_UNBUNDLED)
|
||||
#include <expat.h>
|
||||
#else
|
||||
#include "expat.h"
|
||||
#endif
|
||||
#include <new>
|
||||
#include <cstring>
|
||||
#include <istream>
|
||||
@@ -456,7 +462,7 @@ XMLStreamParser::EventType XMLStreamParser::nextBody()
|
||||
_qualifiedName = &_qname;
|
||||
break; // No more declarations.
|
||||
}
|
||||
// Fall through.
|
||||
[[fallthrough]];
|
||||
}
|
||||
case EV_START_ELEMENT:
|
||||
{
|
||||
@@ -501,7 +507,7 @@ XMLStreamParser::EventType XMLStreamParser::nextBody()
|
||||
_pvalue = &_value;
|
||||
break; // No more attributes.
|
||||
}
|
||||
// Fall through.
|
||||
[[fallthrough]];
|
||||
}
|
||||
case EV_START_ELEMENT:
|
||||
case EV_START_NAMESPACE_DECL:
|
||||
@@ -535,7 +541,7 @@ XMLStreamParser::EventType XMLStreamParser::nextBody()
|
||||
_qualifiedName = &_qname;
|
||||
break; // No more declarations.
|
||||
}
|
||||
// Fall through.
|
||||
[[fallthrough]];
|
||||
}
|
||||
// The end namespace declaration comes before the end element
|
||||
// which means it can follow pretty much any other event.
|
||||
@@ -705,7 +711,7 @@ static void splitName(const XML_Char* s, QName& qn)
|
||||
}
|
||||
|
||||
|
||||
void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name, const XML_Char** atts)
|
||||
void XMLStreamParser::handleStartElement(void* v, const XMLChar* name, const XMLChar** atts)
|
||||
{
|
||||
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
|
||||
|
||||
@@ -789,7 +795,7 @@ void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name,
|
||||
}
|
||||
|
||||
|
||||
void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name)
|
||||
void XMLStreamParser::handleEndElement(void* v, const XMLChar* name)
|
||||
{
|
||||
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
|
||||
|
||||
@@ -828,7 +834,7 @@ void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name)
|
||||
}
|
||||
|
||||
|
||||
void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n)
|
||||
void XMLStreamParser::handleCharacters(void* v, const XMLChar* s, int n)
|
||||
{
|
||||
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
|
||||
|
||||
@@ -899,7 +905,7 @@ void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n
|
||||
}
|
||||
|
||||
|
||||
void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char* prefix, const XML_Char* ns)
|
||||
void XMLStreamParser::handleStartNamespaceDecl(void* v, const XMLChar* prefix, const XMLChar* ns)
|
||||
{
|
||||
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
|
||||
|
||||
@@ -918,7 +924,7 @@ void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char*
|
||||
}
|
||||
|
||||
|
||||
void XMLCALL XMLStreamParser::handleEndNamespaceDecl(void* v, const XML_Char* prefix)
|
||||
void XMLStreamParser::handleEndNamespaceDecl(void* v, const XMLChar* prefix)
|
||||
{
|
||||
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
XMLStreamParserException::~XMLStreamParserException() throw ()
|
||||
XMLStreamParserException::~XMLStreamParserException() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ const std::string& XMLStreamParserException::description() const
|
||||
}
|
||||
|
||||
|
||||
char const* XMLStreamParserException::what() const throw ()
|
||||
char const* XMLStreamParserException::what() const noexcept
|
||||
{
|
||||
return _what.c_str();
|
||||
}
|
||||
|
||||
Vendored
+45
-43
@@ -21,6 +21,9 @@
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
@@ -61,7 +64,7 @@ XMLWriter::XMLWriter(XMLByteOutputStream& str, int options):
|
||||
_pInEncoding(new NATIVE_ENCODING),
|
||||
_pOutEncoding(new Poco::UTF8Encoding),
|
||||
_options(options),
|
||||
_encoding("UTF-8"),
|
||||
_encoding("UTF-8"s),
|
||||
_depth(-1),
|
||||
_elementCount(0),
|
||||
_inFragment(false),
|
||||
@@ -302,7 +305,7 @@ void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& loc
|
||||
else
|
||||
writeStartElement(namespaceURI, localName, qname, attributes);
|
||||
_contentWritten = false;
|
||||
writeMarkup("/");
|
||||
writeMarkup("/"s);
|
||||
closeStartTag();
|
||||
_namespaces.popContext();
|
||||
}
|
||||
@@ -368,14 +371,14 @@ void XMLWriter::processingInstruction(const XMLString& target, const XMLString&
|
||||
{
|
||||
if (_unclosedStartTag) closeStartTag();
|
||||
prettyPrint();
|
||||
writeMarkup("<?");
|
||||
writeMarkup("<?"s);
|
||||
writeXML(target);
|
||||
if (!data.empty())
|
||||
{
|
||||
writeMarkup(MARKUP_SPACE);
|
||||
writeXML(data);
|
||||
}
|
||||
writeMarkup("?>");
|
||||
writeMarkup("?>"s);
|
||||
if (_depth == 0)
|
||||
writeNewLine();
|
||||
}
|
||||
@@ -383,7 +386,7 @@ void XMLWriter::processingInstruction(const XMLString& target, const XMLString&
|
||||
|
||||
namespace
|
||||
{
|
||||
static const XMLString CDATA = toXMLString("CDATA");
|
||||
static const XMLString CDATA = toXMLString("CDATA"s);
|
||||
}
|
||||
|
||||
|
||||
@@ -456,32 +459,32 @@ void XMLWriter::comment(const XMLChar ch[], int start, int length)
|
||||
{
|
||||
if (_unclosedStartTag) closeStartTag();
|
||||
prettyPrint();
|
||||
writeMarkup("<!--");
|
||||
writeMarkup("<!--"s);
|
||||
while (length-- > 0) writeXML(ch[start++]);
|
||||
writeMarkup("-->");
|
||||
writeMarkup("-->"s);
|
||||
_contentWritten = false;
|
||||
}
|
||||
|
||||
|
||||
void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId)
|
||||
{
|
||||
writeMarkup("<!DOCTYPE ");
|
||||
writeMarkup("<!DOCTYPE "s);
|
||||
writeXML(name);
|
||||
if (!publicId.empty())
|
||||
{
|
||||
writeMarkup(" PUBLIC \"");
|
||||
writeMarkup(" PUBLIC \""s);
|
||||
writeXML(publicId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
if (!systemId.empty())
|
||||
{
|
||||
if (publicId.empty())
|
||||
{
|
||||
writeMarkup(" SYSTEM");
|
||||
writeMarkup(" SYSTEM"s);
|
||||
}
|
||||
writeMarkup(" \"");
|
||||
writeMarkup(" \""s);
|
||||
writeXML(systemId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
_inDTD = true;
|
||||
}
|
||||
@@ -493,10 +496,10 @@ void XMLWriter::endDTD()
|
||||
if (_inInternalDTD)
|
||||
{
|
||||
writeNewLine();
|
||||
writeMarkup("]");
|
||||
writeMarkup("]"s);
|
||||
_inInternalDTD = false;
|
||||
}
|
||||
writeMarkup(">");
|
||||
writeMarkup(">"s);
|
||||
writeNewLine();
|
||||
_inDTD = false;
|
||||
}
|
||||
@@ -517,7 +520,7 @@ void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, c
|
||||
if (!_inDTD) throw XMLException("Notation declaration not within DTD");
|
||||
if (!_inInternalDTD)
|
||||
{
|
||||
writeMarkup(" [");
|
||||
writeMarkup(" ["s);
|
||||
_inInternalDTD = true;
|
||||
}
|
||||
if (_options & PRETTY_PRINT)
|
||||
@@ -525,21 +528,21 @@ void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, c
|
||||
writeNewLine();
|
||||
writeMarkup(_indent);
|
||||
}
|
||||
writeMarkup("<!NOTATION ");
|
||||
writeMarkup("<!NOTATION "s);
|
||||
writeXML(name);
|
||||
if (systemId && !systemId->empty())
|
||||
{
|
||||
writeMarkup(" SYSTEM \"");
|
||||
writeMarkup(" SYSTEM \""s);
|
||||
writeXML(*systemId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
if (publicId && !publicId->empty())
|
||||
{
|
||||
writeMarkup(" PUBLIC \"");
|
||||
writeMarkup(" PUBLIC \""s);
|
||||
writeXML(*publicId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
writeMarkup(">");
|
||||
writeMarkup(">"s);
|
||||
}
|
||||
|
||||
|
||||
@@ -548,7 +551,7 @@ void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publi
|
||||
if (!_inDTD) throw XMLException("Entity declaration not within DTD");
|
||||
if (!_inInternalDTD)
|
||||
{
|
||||
writeMarkup(" [");
|
||||
writeMarkup(" ["s);
|
||||
_inInternalDTD = true;
|
||||
}
|
||||
if (_options & PRETTY_PRINT)
|
||||
@@ -556,26 +559,26 @@ void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publi
|
||||
writeNewLine();
|
||||
writeMarkup(_indent);
|
||||
}
|
||||
writeMarkup("<!ENTITY ");
|
||||
writeMarkup("<!ENTITY "s);
|
||||
writeXML(name);
|
||||
if (!systemId.empty())
|
||||
{
|
||||
writeMarkup(" SYSTEM \"");
|
||||
writeMarkup(" SYSTEM \""s);
|
||||
writeXML(systemId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
if (publicId && !publicId->empty())
|
||||
{
|
||||
writeMarkup(" PUBLIC \"");
|
||||
writeMarkup(" PUBLIC \""s);
|
||||
writeXML(*publicId);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
if (!notationName.empty())
|
||||
{
|
||||
writeMarkup(" NDATA ");
|
||||
writeMarkup(" NDATA "s);
|
||||
writeXML(notationName);
|
||||
}
|
||||
writeMarkup(">");
|
||||
writeMarkup(">"s);
|
||||
}
|
||||
|
||||
|
||||
@@ -724,8 +727,7 @@ void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString
|
||||
for (int i = 0; i < attributes.getLength(); i++)
|
||||
{
|
||||
XMLString attributeNamespaceURI = attributes.getURI(i);
|
||||
XMLString attributeLocalName = attributes.getLocalName(i);
|
||||
XMLString attributeQName = attributes.getQName(i);
|
||||
const XMLString& attributeQName = attributes.getQName(i);
|
||||
|
||||
XMLString attributePrefix;
|
||||
XMLString attributeLocal;
|
||||
@@ -774,9 +776,9 @@ void XMLWriter::declareAttributeNamespaces(const Attributes& attributes)
|
||||
{
|
||||
for (int i = 0; i < attributes.getLength(); i++)
|
||||
{
|
||||
XMLString namespaceURI = attributes.getURI(i);
|
||||
XMLString localName = attributes.getLocalName(i);
|
||||
XMLString qname = attributes.getQName(i);
|
||||
const XMLString& namespaceURI = attributes.getURI(i);
|
||||
const XMLString& localName = attributes.getLocalName(i);
|
||||
const XMLString& qname = attributes.getQName(i);
|
||||
if (!localName.empty())
|
||||
{
|
||||
XMLString prefix;
|
||||
@@ -841,8 +843,8 @@ void XMLWriter::addAttributes(AttributeMap& attributeMap, const Attributes& attr
|
||||
{
|
||||
for (int i = 0; i < attributes.getLength(); i++)
|
||||
{
|
||||
XMLString namespaceURI = attributes.getURI(i);
|
||||
XMLString localName = attributes.getLocalName(i);
|
||||
const XMLString& namespaceURI = attributes.getURI(i);
|
||||
const XMLString& localName = attributes.getLocalName(i);
|
||||
XMLString qname = attributes.getQName(i);
|
||||
if (!localName.empty())
|
||||
{
|
||||
@@ -866,8 +868,8 @@ void XMLWriter::addAttributes(CanonicalAttributeMap& attributeMap, const Attribu
|
||||
{
|
||||
for (int i = 0; i < attributes.getLength(); i++)
|
||||
{
|
||||
XMLString namespaceURI = attributes.getURI(i);
|
||||
XMLString localName = attributes.getLocalName(i);
|
||||
const XMLString& namespaceURI = attributes.getURI(i);
|
||||
const XMLString& localName = attributes.getLocalName(i);
|
||||
XMLString qname = attributes.getQName(i);
|
||||
XMLString fullQName = qname;
|
||||
if (!localName.empty())
|
||||
@@ -1030,14 +1032,14 @@ void XMLWriter::writeIndent(int depth) const
|
||||
|
||||
void XMLWriter::writeXMLDeclaration()
|
||||
{
|
||||
writeMarkup("<?xml version=\"1.0\"");
|
||||
writeMarkup("<?xml version=\"1.0\""s);
|
||||
if (!_encoding.empty())
|
||||
{
|
||||
writeMarkup(" encoding=\"");
|
||||
writeMarkup(" encoding=\""s);
|
||||
writeMarkup(_encoding);
|
||||
writeMarkup("\"");
|
||||
writeMarkup("\""s);
|
||||
}
|
||||
writeMarkup("?>");
|
||||
writeMarkup("?>"s);
|
||||
writeNewLine();
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1077
File diff suppressed because it is too large
Load Diff
Vendored
+165
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
|
||||
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
# if defined(_MSC_VER)
|
||||
# define XMLCALL __cdecl
|
||||
# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
|
||||
# define XMLCALL __attribute__((cdecl))
|
||||
# else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
# define XMLCALL
|
||||
# endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
#if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
|
||||
# ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
|
||||
# define XMLIMPORT __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
# endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
#ifndef XML_ENABLE_VISIBILITY
|
||||
# define XML_ENABLE_VISIBILITY 0
|
||||
#endif
|
||||
|
||||
#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
|
||||
# define XMLIMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
# define XMLIMPORT
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) \
|
||||
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
|
||||
# define XML_ATTR_MALLOC __attribute__((__malloc__))
|
||||
#else
|
||||
# define XML_ATTR_MALLOC
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) \
|
||||
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
|
||||
#else
|
||||
# define XML_ATTR_ALLOC_SIZE(x)
|
||||
#endif
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
# ifndef XML_UNICODE
|
||||
# define XML_UNICODE
|
||||
# endif
|
||||
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
|
||||
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
# ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
# else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
# endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
||||
Vendored
+17
-3
@@ -28,9 +28,11 @@
|
||||
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
|
||||
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
|
||||
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com>
|
||||
Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -125,6 +127,9 @@
|
||||
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
|
||||
# elif defined(EMSCRIPTEN) // 32bit mode Emscripten
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu"
|
||||
# else
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
|
||||
@@ -145,7 +150,7 @@
|
||||
8388608 // 8 MiB, 2^23
|
||||
/* NOTE END */
|
||||
|
||||
#include "Poco/XML/expat.h" // so we can use type XML_Parser below
|
||||
#include "expat.h" // so we can use type XML_Parser below
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -154,12 +159,21 @@ extern "C" {
|
||||
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
|
||||
const char **fromLimRef);
|
||||
|
||||
#if defined(XML_DTD)
|
||||
#if defined(XML_GE) && XML_GE == 1
|
||||
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
|
||||
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
|
||||
const char *unsignedCharToPrintable(unsigned char c);
|
||||
#endif
|
||||
|
||||
extern
|
||||
#if ! defined(XML_TESTING)
|
||||
const
|
||||
#endif
|
||||
XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
|
||||
#if defined(XML_TESTING)
|
||||
extern unsigned int g_bytesScanned; // used for testing only
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Vendored
+6
-7
@@ -106,7 +106,7 @@
|
||||
* if this code is included and compiled as C++; related GCC warning is:
|
||||
* warning: use of C++11 long long integer constant [-Wlong-long]
|
||||
*/
|
||||
#define _SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
|
||||
#define SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
|
||||
|
||||
#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
||||
|
||||
@@ -126,8 +126,7 @@
|
||||
| ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
|
||||
| ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
|
||||
|
||||
#define SIPHASH_INITIALIZER \
|
||||
{ 0, 0, 0, 0, {0}, 0, 0 }
|
||||
#define SIPHASH_INITIALIZER {0, 0, 0, 0, {0}, 0, 0}
|
||||
|
||||
struct siphash {
|
||||
uint64_t v0, v1, v2, v3;
|
||||
@@ -190,10 +189,10 @@ sip_round(struct siphash *H, const int rounds) {
|
||||
|
||||
static struct siphash *
|
||||
sip24_init(struct siphash *H, const struct sipkey *key) {
|
||||
H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
|
||||
H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
|
||||
H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
|
||||
H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
|
||||
H->v0 = SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
|
||||
H->v1 = SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
|
||||
H->v2 = SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
|
||||
H->v3 = SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
|
||||
|
||||
H->p = H->buf;
|
||||
H->c = 0;
|
||||
|
||||
Vendored
+823
-388
File diff suppressed because it is too large
Load Diff
Vendored
+5
-5
@@ -12,10 +12,10 @@
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
|
||||
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
|
||||
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
|
||||
Copyright (c) 2021 Donghee Na <donghee.na@python.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -38,15 +38,15 @@
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "expat_config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef EXPAT_WIN32
|
||||
#include "winconfig.h"
|
||||
#endif
|
||||
|
||||
#include "expat_config.h"
|
||||
|
||||
#include "Poco/XML/expat_external.h"
|
||||
#include "expat_external.h"
|
||||
#include "internal.h"
|
||||
#include "xmlrole.h"
|
||||
#include "ascii.h"
|
||||
|
||||
Vendored
+3
-3
@@ -10,7 +10,7 @@
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017-2024 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -127,9 +127,9 @@ typedef struct prolog_state {
|
||||
#endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XmlPrologStateInit(PROLOG_STATE *);
|
||||
void XmlPrologStateInit(PROLOG_STATE *state);
|
||||
#ifdef XML_DTD
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *state);
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
|
||||
Vendored
+14
-19
@@ -12,7 +12,7 @@
|
||||
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
|
||||
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com>
|
||||
Copyright (c) 2016 Don Lewis <truckman@apache.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
@@ -20,8 +20,10 @@
|
||||
Copyright (c) 2017 Benbuck Nason <bnason@netflix.com>
|
||||
Copyright (c) 2017 José Gutiérrez de la Concha <jose@zeroc.com>
|
||||
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
|
||||
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
|
||||
Copyright (c) 2021 Donghee Na <donghee.na@python.org>
|
||||
Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com>
|
||||
Copyright (c) 2022 Sean McBride <sean@rogue-research.com>
|
||||
Copyright (c) 2023 Hanno Böck <hanno@gentoo.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -44,6 +46,8 @@
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "expat_config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h> /* memcpy */
|
||||
#include <stdbool.h>
|
||||
@@ -52,9 +56,7 @@
|
||||
# include "winconfig.h"
|
||||
#endif
|
||||
|
||||
#include "expat_config.h"
|
||||
|
||||
#include "Poco/XML/expat_external.h"
|
||||
#include "expat_external.h"
|
||||
#include "internal.h"
|
||||
#include "xmltok.h"
|
||||
#include "nametab.h"
|
||||
@@ -76,7 +78,7 @@
|
||||
#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
|
||||
|
||||
#define UCS2_GET_NAMING(pages, hi, lo) \
|
||||
(namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))
|
||||
(namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo) & 0x1F)))
|
||||
|
||||
/* A 2 byte UTF-8 representation splits the characters 11 bits between
|
||||
the bottom 5 and 6 bits of the bytes. We need 8 bits to index into
|
||||
@@ -100,7 +102,7 @@
|
||||
& (1u << (((byte)[2]) & 0x1F)))
|
||||
|
||||
/* Detection of invalid UTF-8 sequences is based on Table 3.1B
|
||||
of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
|
||||
of Unicode 3.2: https://www.unicode.org/unicode/reports/tr28/
|
||||
with the additional restriction of not allowing the Unicode
|
||||
code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE).
|
||||
Implementation details:
|
||||
@@ -225,7 +227,7 @@ struct normal_encoding {
|
||||
/* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \
|
||||
/* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL
|
||||
|
||||
static int FASTCALL checkCharRefNumber(int);
|
||||
static int FASTCALL checkCharRefNumber(int result);
|
||||
|
||||
#include "xmltok_impl.h"
|
||||
#include "ascii.h"
|
||||
@@ -243,7 +245,7 @@ static int FASTCALL checkCharRefNumber(int);
|
||||
#endif
|
||||
|
||||
#define SB_BYTE_TYPE(enc, p) \
|
||||
(((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
|
||||
(((const struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
|
||||
|
||||
#ifdef XML_MIN_SIZE
|
||||
static int PTRFASTCALL
|
||||
@@ -407,7 +409,7 @@ utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim,
|
||||
unsigned short *to = *toP;
|
||||
const char *from = *fromP;
|
||||
while (from < fromLim && to < toLim) {
|
||||
switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
|
||||
switch (SB_BYTE_TYPE(enc, from)) {
|
||||
case BT_LEAD2:
|
||||
if (fromLim - from < 2) {
|
||||
res = XML_CONVERT_INPUT_INCOMPLETE;
|
||||
@@ -715,31 +717,26 @@ unicode_byte_type(char hi, char lo) {
|
||||
return res; \
|
||||
}
|
||||
|
||||
#define SET2(ptr, ch) (((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8)))
|
||||
#define GET_LO(ptr) ((unsigned char)(ptr)[0])
|
||||
#define GET_HI(ptr) ((unsigned char)(ptr)[1])
|
||||
|
||||
DEFINE_UTF16_TO_UTF8(little2_)
|
||||
DEFINE_UTF16_TO_UTF16(little2_)
|
||||
|
||||
#undef SET2
|
||||
#undef GET_LO
|
||||
#undef GET_HI
|
||||
|
||||
#define SET2(ptr, ch) (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF)))
|
||||
#define GET_LO(ptr) ((unsigned char)(ptr)[1])
|
||||
#define GET_HI(ptr) ((unsigned char)(ptr)[0])
|
||||
|
||||
DEFINE_UTF16_TO_UTF8(big2_)
|
||||
DEFINE_UTF16_TO_UTF16(big2_)
|
||||
|
||||
#undef SET2
|
||||
#undef GET_LO
|
||||
#undef GET_HI
|
||||
|
||||
#define LITTLE2_BYTE_TYPE(enc, p) \
|
||||
((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
|
||||
: unicode_byte_type((p)[1], (p)[0]))
|
||||
((p)[1] == 0 ? SB_BYTE_TYPE(enc, p) : unicode_byte_type((p)[1], (p)[0]))
|
||||
#define LITTLE2_BYTE_TO_ASCII(p) ((p)[1] == 0 ? (p)[0] : -1)
|
||||
#define LITTLE2_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == (c))
|
||||
#define LITTLE2_IS_NAME_CHAR_MINBPC(p) \
|
||||
@@ -872,9 +869,7 @@ static const struct normal_encoding internal_little2_encoding
|
||||
#endif
|
||||
|
||||
#define BIG2_BYTE_TYPE(enc, p) \
|
||||
((p)[0] == 0 \
|
||||
? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
|
||||
: unicode_byte_type((p)[0], (p)[1]))
|
||||
((p)[0] == 0 ? SB_BYTE_TYPE(enc, p + 1) : unicode_byte_type((p)[0], (p)[1]))
|
||||
#define BIG2_BYTE_TO_ASCII(p) ((p)[0] == 0 ? (p)[1] : -1)
|
||||
#define BIG2_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == (c))
|
||||
#define BIG2_IS_NAME_CHAR_MINBPC(p) \
|
||||
|
||||
Vendored
+5
-3
@@ -10,7 +10,7 @@
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2002-2005 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
Licensed under the MIT license:
|
||||
|
||||
@@ -289,7 +289,8 @@ int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr, int *standalonePtr);
|
||||
|
||||
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
int XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||
@@ -307,7 +308,8 @@ int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr, int *standalonePtr);
|
||||
|
||||
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
int XmlInitEncodingNS(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
|
||||
|
||||
Vendored
+1
-1
@@ -126,7 +126,7 @@
|
||||
# endif
|
||||
|
||||
# define HAS_CHARS(enc, ptr, end, count) \
|
||||
((end) - (ptr) >= ((count)*MINBPC(enc)))
|
||||
((end) - (ptr) >= ((count) * MINBPC(enc)))
|
||||
|
||||
# define HAS_CHAR(enc, ptr, end) HAS_CHARS(enc, ptr, end, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user