1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-11-05 16:57:18 +01:00

Update POCO library.

This commit is contained in:
Sandu Liviu Catalin
2023-03-23 20:19:11 +02:00
parent 8d15f4b6e9
commit 233fc103f9
2521 changed files with 257092 additions and 72789 deletions

View File

@@ -233,7 +233,7 @@ void AbstractNode::addEventListener(const XMLString& type, EventListener* listen
_pEventDispatcher->removeEventListener(type, listener, useCapture);
else
_pEventDispatcher = new EventDispatcher;
_pEventDispatcher->addEventListener(type, listener, useCapture);
}
@@ -276,7 +276,7 @@ void AbstractNode::captureEvent(Event* evt)
{
if (_pParent)
_pParent->captureEvent(evt);
if (_pEventDispatcher && !evt->isStopped())
{
evt->setCurrentTarget(this);

View File

@@ -30,7 +30,7 @@ Attr::Attr(Document* pOwnerDocument, Element* pOwnerElement, const XMLString& na
}
Attr::Attr(Document* pOwnerDocument, const Attr& attr):
Attr::Attr(Document* pOwnerDocument, const Attr& attr):
AbstractNode(pOwnerDocument, attr),
_name(pOwnerDocument->namePool().insert(attr._name)),
_value(attr._value),

View File

@@ -27,7 +27,7 @@ AttrMap::AttrMap(Element* pElement):
_pElement(pElement)
{
poco_check_ptr (pElement);
_pElement->duplicate();
}
@@ -50,7 +50,7 @@ Node* AttrMap::setNamedItem(Node* arg)
if (arg->nodeType() != Node::ATTRIBUTE_NODE)
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
return _pElement->setAttributeNode(static_cast<Attr*>(arg));
}
@@ -77,7 +77,7 @@ unsigned long AttrMap::length() const
{
unsigned long result = 0;
AbstractNode* pAttr = _pElement->_pFirstAttr;
while (pAttr)
while (pAttr)
{
pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
++result;

View File

@@ -278,7 +278,7 @@ AttributesImpl::Attribute* AttributesImpl::find(const XMLString& qname) const
{
for (AttributeVec::const_iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->qname == qname)
if (it->qname == qname)
return const_cast<Attribute*>(&(*it));
}
return 0;
@@ -289,7 +289,7 @@ AttributesImpl::Attribute* AttributesImpl::find(const XMLString& namespaceURI, c
{
for (AttributeVec::const_iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->namespaceURI == namespaceURI && it->localName == localName)
if (it->namespaceURI == namespaceURI && it->localName == localName)
return const_cast<Attribute*>(&(*it));
}
return 0;

View File

@@ -24,13 +24,13 @@ namespace XML {
const XMLString CDATASection::NODE_NAME = toXMLString("#cdata-section");
CDATASection::CDATASection(Document* pOwnerDocument, const XMLString& data):
CDATASection::CDATASection(Document* pOwnerDocument, const XMLString& data):
Text(pOwnerDocument, data)
{
}
CDATASection::CDATASection(Document* pOwnerDocument, const CDATASection& sec):
CDATASection::CDATASection(Document* pOwnerDocument, const CDATASection& sec):
Text(pOwnerDocument, sec)
{
}

View File

@@ -21,14 +21,14 @@ namespace Poco {
namespace XML {
CharacterData::CharacterData(Document* pOwnerDocument, const XMLString& data):
CharacterData::CharacterData(Document* pOwnerDocument, const XMLString& data):
AbstractNode(pOwnerDocument),
_data(data)
{
}
CharacterData::CharacterData(Document* pOwnerDocument, const CharacterData& data):
CharacterData::CharacterData(Document* pOwnerDocument, const CharacterData& data):
AbstractNode(pOwnerDocument, data),
_data(data._data)
{

View File

@@ -22,13 +22,13 @@ namespace XML {
const XMLString Comment::NODE_NAME = toXMLString("#comment");
Comment::Comment(Document* pOwnerDocument, const XMLString& data):
Comment::Comment(Document* pOwnerDocument, const XMLString& data):
CharacterData(pOwnerDocument, data)
{
}
Comment::Comment(Document* pOwnerDocument, const Comment& comment):
Comment::Comment(Document* pOwnerDocument, const Comment& comment):
CharacterData(pOwnerDocument, comment)
{
}

View File

@@ -47,19 +47,19 @@ DOMException::DOMException(unsigned short code):
{
}
DOMException::DOMException(const DOMException& exc):
XMLException(exc),
_code(exc._code)
{
}
DOMException::~DOMException() noexcept
{
}
DOMException& DOMException::operator = (const DOMException& exc)
{
if (&exc != this)

View File

@@ -53,7 +53,7 @@ bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& ve
(lcFeature == FEATURE_TRAVERSAL && version == VERSION_2_0);
}
DocumentType* DOMImplementation::createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const
{
return new DocumentType(0, name, publicId, systemId);

View File

@@ -23,7 +23,7 @@ DOMObject::DOMObject(): _rc(1)
{
}
DOMObject::~DOMObject()
{
}

View File

@@ -198,25 +198,25 @@ void DOMSerializer::handleNode(const Node* pNode) const
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
handleElement(static_cast<const Element*>(pNode));
handleElement(static_cast<const Element*>(pNode));
break;
case Node::TEXT_NODE:
handleCharacterData(static_cast<const Text*>(pNode));
handleCharacterData(static_cast<const Text*>(pNode));
break;
case Node::CDATA_SECTION_NODE:
handleCDATASection(static_cast<const CDATASection*>(pNode));
handleCDATASection(static_cast<const CDATASection*>(pNode));
break;
case Node::ENTITY_NODE:
handleEntity(static_cast<const Entity*>(pNode));
break;
case Node::PROCESSING_INSTRUCTION_NODE:
handlePI(static_cast<const ProcessingInstruction*>(pNode));
handlePI(static_cast<const ProcessingInstruction*>(pNode));
break;
case Node::COMMENT_NODE:
handleComment(static_cast<const Comment*>(pNode));
handleComment(static_cast<const Comment*>(pNode));
break;
case Node::DOCUMENT_NODE:
handleDocument(static_cast<const Document*>(pNode));
handleDocument(static_cast<const Document*>(pNode));
break;
case Node::DOCUMENT_TYPE_NODE:
handleDocumentType(static_cast<const DocumentType*>(pNode));
@@ -233,7 +233,7 @@ void DOMSerializer::handleNode(const Node* pNode) const
void DOMSerializer::handleElement(const Element* pElement) const
{
if (_pContentHandler)
if (_pContentHandler)
{
AutoPtr<NamedNodeMap> pAttrs = pElement->attributes();
AttributesImpl saxAttrs;

View File

@@ -77,7 +77,7 @@ void DOMWriter::writeNode(XMLByteOutputStream& ostr, const Node* pNode)
XMLWriter writer(ostr, _options, _encodingName, _pTextEncoding);
writer.setNewLine(_newLine);
writer.setIndent(_indent);
DOMSerializer serializer;
serializer.setContentHandler(&writer);
serializer.setDTDHandler(&writer);
@@ -93,7 +93,7 @@ void DOMWriter::writeNode(const std::string& systemId, const Node* pNode)
Poco::FileOutputStream ostr(systemId);
if (ostr.good())
writeNode(ostr, pNode);
else
else
throw Poco::CreateFileException(systemId);
}

View File

@@ -38,7 +38,7 @@ namespace XML {
const XMLString Document::NODE_NAME = toXMLString("#document");
Document::Document(NamePool* pNamePool):
Document::Document(NamePool* pNamePool):
AbstractContainerNode(0),
_pDocumentType(0),
_eventSuspendLevel(0)
@@ -55,7 +55,7 @@ Document::Document(NamePool* pNamePool):
}
Document::Document(unsigned long namePoolSize):
Document::Document(unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(0),
_pNamePool(new NamePool(namePoolSize)),
@@ -64,7 +64,7 @@ Document::Document(unsigned long namePoolSize):
}
Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
_eventSuspendLevel(0)
@@ -86,7 +86,7 @@ Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
}
Document::Document(DocumentType* pDocumentType, unsigned long namePoolSize):
Document::Document(DocumentType* pDocumentType, unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
_pNamePool(new NamePool(namePoolSize)),
@@ -155,7 +155,7 @@ Element* Document::documentElement() const
Element* Document::createElement(const XMLString& tagName) const
{
return new Element(const_cast<Document*>(this), EMPTY_STRING, EMPTY_STRING, tagName);
return new Element(const_cast<Document*>(this), EMPTY_STRING, EMPTY_STRING, tagName);
}
@@ -203,7 +203,7 @@ EntityReference* Document::createEntityReference(const XMLString& name) const
NodeList* Document::getElementsByTagName(const XMLString& name) const
{
return new ElementsByTagNameList(const_cast<Document*>(this), name);
return new ElementsByTagNameList(const_cast<Document*>(this), name);
}
@@ -239,7 +239,7 @@ Attr* Document::createAttributeNS(const XMLString& namespaceURI, const XMLString
NodeList* Document::getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return new ElementsByTagNameListNS(const_cast<Document*>(this), namespaceURI, localName);
return new ElementsByTagNameListNS(const_cast<Document*>(this), namespaceURI, localName);
}

View File

@@ -22,13 +22,13 @@ namespace XML {
const XMLString DocumentFragment::NODE_NAME = toXMLString("#document-fragment");
DocumentFragment::DocumentFragment(Document* pOwnerDocument):
DocumentFragment::DocumentFragment(Document* pOwnerDocument):
AbstractContainerNode(pOwnerDocument)
{
}
DocumentFragment::DocumentFragment( Document* pOwnerDocument, const DocumentFragment& fragment):
DocumentFragment::DocumentFragment( Document* pOwnerDocument, const DocumentFragment& fragment):
AbstractContainerNode(pOwnerDocument, fragment)
{
}

View File

@@ -22,7 +22,7 @@ namespace Poco {
namespace XML {
DocumentType::DocumentType(Document* pOwner, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
DocumentType::DocumentType(Document* pOwner, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
AbstractContainerNode(pOwner),
_name(name),
_publicId(publicId),
@@ -31,7 +31,7 @@ DocumentType::DocumentType(Document* pOwner, const XMLString& name, const XMLStr
}
DocumentType::DocumentType(Document* pOwner, const DocumentType& doctype):
DocumentType::DocumentType(Document* pOwner, const DocumentType& doctype):
AbstractContainerNode(pOwner, doctype),
_name(doctype._name),
_publicId(doctype._publicId),

View File

@@ -33,7 +33,7 @@ Element::Element(Document* pOwnerDocument, const XMLString& namespaceURI, const
}
Element::Element(Document* pOwnerDocument, const Element& element):
Element::Element(Document* pOwnerDocument, const Element& element):
AbstractContainerNode(pOwnerDocument, element),
_name(pOwnerDocument->namePool().insert(element._name)),
_pFirstAttr(0)
@@ -129,7 +129,7 @@ Attr* Element::removeAttributeNode(Attr* oldAttr)
{
poco_check_ptr (oldAttr);
if (_pOwner->events())
if (_pOwner->events())
dispatchAttrModified(oldAttr, MutationEvent::REMOVAL, oldAttr->getValue(), EMPTY_STRING);
if (oldAttr != _pFirstAttr)

View File

@@ -28,7 +28,7 @@ ElementsByTagNameList::ElementsByTagNameList(const Node* pParent, const XMLStrin
_count(0)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}
@@ -94,7 +94,7 @@ ElementsByTagNameListNS::ElementsByTagNameListNS(const Node* pParent, const XMLS
_count(0)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}

View File

@@ -22,7 +22,7 @@ namespace XML {
const XMLString Entity::NODE_NAME = toXMLString("#entity");
Entity::Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName):
Entity::Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName):
AbstractContainerNode(pOwnerDocument),
_name(name),
_publicId(publicId),
@@ -32,7 +32,7 @@ Entity::Entity(Document* pOwnerDocument, const XMLString& name, const XMLString&
}
Entity::Entity(Document* pOwnerDocument, const Entity& entity):
Entity::Entity(Document* pOwnerDocument, const Entity& entity):
AbstractContainerNode(pOwnerDocument, entity),
_name(entity._name),
_publicId(entity._publicId),

View File

@@ -19,14 +19,14 @@ namespace Poco {
namespace XML {
EntityReference::EntityReference(Document* pOwnerDocument, const XMLString& name):
EntityReference::EntityReference(Document* pOwnerDocument, const XMLString& name):
AbstractNode(pOwnerDocument),
_name(name)
{
}
EntityReference::EntityReference(Document* pOwnerDocument, const EntityReference& ref):
EntityReference::EntityReference(Document* pOwnerDocument, const EntityReference& ref):
AbstractNode(pOwnerDocument, ref),
_name(ref._name)
{

View File

@@ -58,7 +58,7 @@ InputSource* EntityResolverImpl::resolveEntity(const XMLString* publicId, const
return pInputSource;
}
void EntityResolverImpl::releaseInputSource(InputSource* pSource)
{
poco_check_ptr (pSource);

View File

@@ -17,7 +17,7 @@
#include "Poco/DOM/EventListener.h"
namespace
namespace
{
class DispatchGuard
{
@@ -27,12 +27,12 @@ namespace
{
++_count;
}
~DispatchGuard()
{
--_count;
}
private:
int& _count;
};
@@ -48,7 +48,7 @@ EventDispatcher::EventDispatcher():
{
}
EventDispatcher::~EventDispatcher()
{
}

View File

@@ -28,7 +28,7 @@ const XMLString MutationEvent::DOMAttrModified = toXMLString("DOMAtt
const XMLString MutationEvent::DOMCharacterDataModified = toXMLString("DOMCharacterDataModified");
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type):
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type):
Event(pOwnerDocument, type, 0, true, false),
_change(MODIFICATION),
_pRelatedNode(0)
@@ -44,7 +44,7 @@ MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type, Ev
}
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode,
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode,
const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change):
Event(pOwnerDocument, type, pTarget, canBubble, cancelable),
_prevValue(prevValue),
@@ -61,7 +61,7 @@ MutationEvent::~MutationEvent()
}
void MutationEvent::initMutationEvent(const XMLString& type, bool canBubble, bool cancelable, Node* relatedNode,
void MutationEvent::initMutationEvent(const XMLString& type, bool canBubble, bool cancelable, Node* relatedNode,
const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change)
{
initEvent(type, canBubble, cancelable);
@@ -72,5 +72,5 @@ void MutationEvent::initMutationEvent(const XMLString& type, bool canBubble, boo
_change = change;
}
} } // namespace Poco::XML

View File

@@ -65,7 +65,7 @@ Name::Name(Name&& name) noexcept:
{
}
Name::~Name()
{
}
@@ -93,7 +93,7 @@ Name& Name::operator = (Name&& name) noexcept
}
void Name::swap(Name& name)
void Name::swap(Name& name) noexcept
{
std::swap(_qname, name._qname);
std::swap(_namespaceURI, name._namespaceURI);
@@ -168,7 +168,7 @@ void Name::split(const XMLString& qname, XMLString& prefix, XMLString& localName
XMLString Name::localName(const XMLString& qname)
{
XMLString::size_type pos = qname.find(':');
if (pos != XMLString::npos)
if (pos != XMLString::npos)
return XMLString(qname, pos + 1, qname.size() - pos - 1);
else
return qname;

View File

@@ -27,11 +27,11 @@ public:
NamePoolItem(): _used(false)
{
}
~NamePoolItem()
{
}
bool set(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
{
if (!_used)
@@ -42,24 +42,24 @@ public:
}
else return _name.equals(qname, namespaceURI, localName);
}
const Name& get() const
{
return _name;
}
bool used() const
{
return _used;
}
private:
Name _name;
bool _used;
};
NamePool::NamePool(unsigned long size):
NamePool::NamePool(unsigned long size):
_size(size),
_salt(0),
_rc(1)
@@ -67,7 +67,7 @@ NamePool::NamePool(unsigned long size):
poco_assert (size > 1);
_pItems = new NamePoolItem[size];
Poco::Random rnd;
rnd.seed();
_salt = rnd.next();
@@ -98,9 +98,9 @@ const Name& NamePool::insert(const XMLString& qname, const XMLString& namespaceU
unsigned long i = 0;
unsigned long n = (hash(qname, namespaceURI, localName) ^ _salt) % _size;
while (!_pItems[n].set(qname, namespaceURI, localName) && i++ < _size)
while (!_pItems[n].set(qname, namespaceURI, localName) && i++ < _size)
n = (n + 1) % _size;
if (i > _size) throw Poco::PoolOverflowException("XML name pool");
return _pItems[n].get();

View File

@@ -62,12 +62,12 @@ void NamespaceStrategy::splitName(const XMLChar* qname, XMLString& uri, XMLStrin
else
prefix.assign(XML_LIT(""));
}
else
else
{
uri.assign(XML_LIT(""));
localName = qname;
prefix.assign(XML_LIT(""));
}
}
}

View File

@@ -82,7 +82,7 @@ const XMLString& NamespaceSupport::getPrefix(const XMLString& namespaceURI) cons
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
if (it->second == namespaceURI)
if (it->second == namespaceURI)
return it->first;
}
}
@@ -96,7 +96,7 @@ bool NamespaceSupport::isMapped(const XMLString& namespaceURI) const
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
if (it->second == namespaceURI)
if (it->second == namespaceURI)
return true;
}
}
@@ -112,7 +112,7 @@ void NamespaceSupport::getPrefixes(PrefixSet& prefixes) const
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
const XMLString& prefix = it->first;
if (!prefix.empty() && prefixes.find(prefix) == prefixes.end())
if (!prefix.empty() && prefixes.find(prefix) == prefixes.end())
prefixes.insert(it->first);
}
}
@@ -127,7 +127,7 @@ void NamespaceSupport::getPrefixes(const XMLString& namespaceURI, PrefixSet& pre
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
const XMLString& prefix = it->first;
if (it->second == namespaceURI && !prefix.empty() && prefixes.find(prefix) == prefixes.end())
if (it->second == namespaceURI && !prefix.empty() && prefixes.find(prefix) == prefixes.end())
prefixes.insert(it->first);
}
}
@@ -139,7 +139,7 @@ const XMLString& NamespaceSupport::getURI(const XMLString& prefix) const
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
Context::const_iterator it = rit->find(prefix);
if (it != rit->end())
if (it != rit->end())
return it->second;
}
return EMPTY_STRING;

View File

@@ -43,7 +43,7 @@ void NodeAppender::appendChild(Node* newChild)
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pParent->_pOwner)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
@@ -67,7 +67,7 @@ void NodeAppender::appendChild(Node* newChild)
{
AbstractNode* pAN = static_cast<AbstractNode*>(newChild);
pAN->duplicate();
if (pAN->_pParent)
if (pAN->_pParent)
pAN->_pParent->removeChild(pAN);
pAN->_pParent = _pParent;
if (_pLast)

View File

@@ -30,7 +30,7 @@ NodeIterator::NodeIterator(Node* root, unsigned long whatToShow, NodeFilter* pFi
{
}
NodeIterator::NodeIterator(const NodeIterator& iterator):
_pRoot(iterator._pRoot),
_whatToShow(iterator._whatToShow),
@@ -39,7 +39,7 @@ NodeIterator::NodeIterator(const NodeIterator& iterator):
{
}
NodeIterator& NodeIterator::operator = (const NodeIterator& iterator)
{
if (&iterator != this)
@@ -52,7 +52,7 @@ NodeIterator& NodeIterator::operator = (const NodeIterator& iterator)
return *this;
}
NodeIterator::~NodeIterator()
{
}
@@ -61,7 +61,7 @@ NodeIterator::~NodeIterator()
Node* NodeIterator::nextNode()
{
if (!_pRoot) throw DOMException(DOMException::INVALID_STATE_ERR);
if (_pCurrent)
_pCurrent = next();
else
@@ -98,30 +98,30 @@ bool NodeIterator::accept(Node* pNode) const
bool accept = false;
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
case Node::ELEMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ELEMENT) != 0; break;
case Node::ATTRIBUTE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
case Node::TEXT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
case Node::CDATA_SECTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
case Node::ENTITY_REFERENCE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
case Node::ENTITY_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
case Node::PROCESSING_INSTRUCTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
case Node::COMMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
case Node::DOCUMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
case Node::DOCUMENT_TYPE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
case Node::DOCUMENT_FRAGMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
case Node::NOTATION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
}
if (accept && _pFilter)
accept = _pFilter->acceptNode(pNode) == NodeFilter::FILTER_ACCEPT;

View File

@@ -19,7 +19,7 @@ namespace Poco {
namespace XML {
Notation::Notation(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
Notation::Notation(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
AbstractNode(pOwnerDocument),
_name(name),
_publicId(publicId),
@@ -28,7 +28,7 @@ Notation::Notation(Document* pOwnerDocument, const XMLString& name, const XMLStr
}
Notation::Notation(Document* pOwnerDocument, const Notation& notation):
Notation::Notation(Document* pOwnerDocument, const Notation& notation):
AbstractNode(pOwnerDocument, notation),
_name(notation._name),
_publicId(notation._publicId),

View File

@@ -504,7 +504,7 @@ void ParserEngine::init()
XML_SetParamEntityParsing(_parser, _externalParameterEntities ? XML_PARAM_ENTITY_PARSING_ALWAYS : XML_PARAM_ENTITY_PARSING_NEVER);
XML_SetUnknownEncodingHandler(_parser, handleUnknownEncoding, this);
#if XML_MAJOR_VERSION > 2 || (XML_MAJOR_VERSION == 2 && XML_MINOR_VERSION >= 4)
#if defined(XML_DTD) && (XML_MAJOR_VERSION > 2 || (XML_MAJOR_VERSION == 2 && XML_MINOR_VERSION >= 4))
if (_maximumAmplificationFactor > 1.0)
{
XML_SetBillionLaughsAttackProtectionMaximumAmplification(_parser, _maximumAmplificationFactor);
@@ -604,7 +604,7 @@ void ParserEngine::handleError(int errorNo)
throw SAXParseException("Reserved prefix 'xmlns' must not be declared or undeclared", locator());
case XML_ERROR_RESERVED_NAMESPACE_URI:
throw SAXParseException("Prefix must not be bound to one of the reserved namespace names", locator());
#if XML_MAJOR_VERSION > 2 || XML_MINOR_VERSION >= 1
#if XML_MAJOR_VERSION > 2 || (XML_MINOR_VERSION >= 2 && XML_MICRO_VERSION >= 1)
case XML_ERROR_INVALID_ARGUMENT:
throw SAXParseException("Invalid argument", locator());
#endif

View File

@@ -19,7 +19,7 @@ namespace Poco {
namespace XML {
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const XMLString& target, const XMLString& data):
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const XMLString& target, const XMLString& data):
AbstractNode(pOwnerDocument),
_target(target),
_data(data)
@@ -27,7 +27,7 @@ ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const XML
}
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const ProcessingInstruction& processingInstruction):
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const ProcessingInstruction& processingInstruction):
AbstractNode(pOwnerDocument, processingInstruction),
_target(processingInstruction._target),
_data(processingInstruction._data)

View File

@@ -78,12 +78,12 @@ QName& QName::operator = (QName&& qname) noexcept
_ns = std::move(qname._ns);
_name = std::move(qname._name);
_prefix = std::move(qname._prefix);
return *this;
}
void QName::swap(QName& qname)
void QName::swap(QName& qname) noexcept
{
std::swap(_ns, qname._ns);
std::swap(_name, qname._name);

View File

@@ -46,7 +46,7 @@ SAXParseException::SAXParseException(const std::string& msg, const Locator& loc,
{
}
SAXParseException::SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber):
SAXException(buildMessage(msg, publicId, systemId, lineNumber, columnNumber)),
_publicId(publicId),
@@ -95,7 +95,7 @@ SAXParseException& SAXParseException::operator = (const SAXParseException& exc)
return *this;
}
const char* SAXParseException::name() const noexcept
{
return "SAXParseException";

View File

@@ -24,13 +24,13 @@ namespace XML {
const XMLString Text::NODE_NAME = toXMLString("#text");
Text::Text(Document* pOwnerDocument, const XMLString& data):
Text::Text(Document* pOwnerDocument, const XMLString& data):
CharacterData(pOwnerDocument, data)
{
}
Text::Text(Document* pOwnerDocument, const Text& text):
Text::Text(Document* pOwnerDocument, const Text& text):
CharacterData(pOwnerDocument, text)
{
}

View File

@@ -29,7 +29,7 @@ TreeWalker::TreeWalker(Node* root, unsigned long whatToShow, NodeFilter* pFilter
{
}
TreeWalker::TreeWalker(const TreeWalker& walker):
_pRoot(walker._pRoot),
_whatToShow(walker._whatToShow),
@@ -38,7 +38,7 @@ TreeWalker::TreeWalker(const TreeWalker& walker):
{
}
TreeWalker& TreeWalker::operator = (const TreeWalker& walker)
{
if (&walker != this)
@@ -51,7 +51,7 @@ TreeWalker& TreeWalker::operator = (const TreeWalker& walker)
return *this;
}
TreeWalker::~TreeWalker()
{
}
@@ -66,7 +66,7 @@ void TreeWalker::setCurrentNode(Node* pNode)
Node* TreeWalker::parentNode()
{
if (!_pCurrent || _pCurrent == _pRoot) return 0;
Node* pParent = _pCurrent->parentNode();
while (pParent && pParent != _pRoot && accept(pParent) != NodeFilter::FILTER_ACCEPT)
pParent = pParent->parentNode();
@@ -133,7 +133,7 @@ Node* TreeWalker::nextSibling()
Node* TreeWalker::previousNode()
{
if (!_pCurrent) return 0;
Node* pPrev = previous(_pCurrent);
while (pPrev && accept(pPrev) != NodeFilter::FILTER_ACCEPT)
pPrev = previous(pPrev);
@@ -161,30 +161,30 @@ int TreeWalker::accept(Node* pNode) const
bool accept = false;
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
case Node::ELEMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ELEMENT) != 0; break;
case Node::ATTRIBUTE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
case Node::TEXT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
case Node::CDATA_SECTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
case Node::ENTITY_REFERENCE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
case Node::ENTITY_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
case Node::PROCESSING_INSTRUCTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
case Node::COMMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
case Node::DOCUMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
case Node::DOCUMENT_TYPE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
case Node::DOCUMENT_FRAGMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
case Node::NOTATION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
}
if (accept && _pFilter)
return _pFilter->acceptNode(pNode);

View File

@@ -26,8 +26,8 @@ WhitespaceFilter::WhitespaceFilter():
{
}
WhitespaceFilter::WhitespaceFilter(XMLReader* pReader):
WhitespaceFilter::WhitespaceFilter(XMLReader* pReader):
XMLFilterImpl(pReader),
_pLexicalHandler(0),
_filter(true)
@@ -121,7 +121,7 @@ void WhitespaceFilter::characters(const XMLChar ch[], int start, int length)
{
XMLFilterImpl::characters(_data.data(), 0, (int) _data.length());
_filter = false;
_data.clear();
_data.clear();
}
}
else XMLFilterImpl::characters(ch, start, length);

View File

@@ -29,7 +29,7 @@ XMLFilterImpl::XMLFilterImpl():
{
}
XMLFilterImpl::XMLFilterImpl(XMLReader* pParent):
_pParent(pParent),
_pEntityResolver(0),
@@ -39,7 +39,7 @@ XMLFilterImpl::XMLFilterImpl(XMLReader* pParent):
{
}
XMLFilterImpl::~XMLFilterImpl()
{
}

View File

@@ -31,7 +31,7 @@ std::string fromXMLString(const XMLString& str)
{
std::string result;
result.reserve(str.size());
for (auto xc: str)
{
char c;
@@ -46,7 +46,7 @@ XMLString toXMLString(const std::string& str)
{
XMLString result;
result.reserve(str.size());
for (std::string::const_iterator it = str.begin(); it != str.end();)
{
wchar_t c;

View File

@@ -193,7 +193,7 @@ void XMLWriter::startDocument()
if (_options & WRITE_XML_DECLARATION)
writeXMLDeclaration();
_contentWritten = true;
_namespaces.reset();
_namespaces.pushContext();
@@ -234,7 +234,7 @@ void XMLWriter::endFragment()
{
if (_depth > 1)
throw XMLException("Not well-formed (at least one tag has no matching end tag)");
_inFragment = false;
_elementCount = 0;
_depth = -1;
@@ -250,14 +250,14 @@ void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& loc
void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
if (_depth == 0 && !_inFragment && _elementCount > 1)
if (_depth == 0 && !_inFragment && _elementCount > 1)
throw XMLException("Not well-formed. Second root element found", nameToString(localName, qname));
if (_unclosedStartTag) closeStartTag();
prettyPrint();
if (_options & CANONICAL_XML)
writeCanonicalStartElement(namespaceURI, localName, qname, attributes);
else
else
writeStartElement(namespaceURI, localName, qname, attributes);
_elementStack.emplace_back(qname, namespaceURI, localName);
_contentWritten = false;
@@ -595,7 +595,7 @@ void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString
_namespaces.pushContext();
_nsContextPushed = false;
++_elementCount;
declareAttributeNamespaces(attributes);
writeMarkup(MARKUP_LT);
@@ -643,7 +643,7 @@ void XMLWriter::writeCanonicalStartElement(const XMLString& namespaceURI, const
_namespaces.pushContext();
_nsContextPushed = false;
++_elementCount;
declareNamespaces(namespaceURI, localName, qname, attributes);
writeMarkup(MARKUP_LT);
@@ -726,7 +726,7 @@ void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString
XMLString attributeNamespaceURI = attributes.getURI(i);
XMLString attributeLocalName = attributes.getLocalName(i);
XMLString attributeQName = attributes.getQName(i);
XMLString attributePrefix;
XMLString attributeLocal;
Name::split(attributeQName, attributePrefix, attributeLocal);
@@ -744,7 +744,7 @@ void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString
for (const auto& nsURI: namespaceURIs)
{
XMLString prefix = p.first;
if (prefix.empty())
if (prefix.empty())
prefix = _namespaces.getPrefix(nsURI);
if (prefix.empty() && !_namespaces.isMapped(nsURI))
{
@@ -761,7 +761,7 @@ void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString
}
const XMLString& uri = _namespaces.getURI(prefix);
if ((uri.empty() || uri != nsURI) && !nsURI.empty())
if ((uri.empty() || uri != nsURI) && !nsURI.empty())
{
_namespaces.declarePrefix(prefix, nsURI);
}
@@ -807,7 +807,7 @@ void XMLWriter::addNamespaceAttributes(AttributeMap& attributeMap)
{
XMLString uri = _namespaces.getURI(prefix);
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
if (!prefix.empty())
{
qname.append(toXMLString(MARKUP_COLON));
@@ -826,7 +826,7 @@ void XMLWriter::addNamespaceAttributes(CanonicalAttributeMap& attributeMap)
{
XMLString uri = _namespaces.getURI(prefix);
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
if (!prefix.empty())
{
qname.append(toXMLString(MARKUP_COLON));
@@ -923,7 +923,7 @@ void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
default:
if (c >= 0 && c < 32)
throw XMLException("Invalid character token.");
else
else
writeXML(c);
}
}
@@ -961,7 +961,7 @@ void XMLWriter::writeAttributes(const CanonicalAttributeMap& attributeMap)
default:
if (c >= 0 && c < 32)
throw XMLException("Invalid character token.");
else
else
writeXML(c);
}
}
@@ -1001,8 +1001,8 @@ void XMLWriter::writeName(const XMLString& prefix, const XMLString& localName)
}
else
{
writeXML(prefix);
writeMarkup(MARKUP_COLON);
writeXML(prefix);
writeMarkup(MARKUP_COLON);
writeXML(localName);
}
}

View File

@@ -33,34 +33,34 @@
*/
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

View File

@@ -34,34 +34,34 @@
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

View File

@@ -28,7 +28,7 @@
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-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
@@ -107,7 +107,9 @@
#include <limits.h> // ULONG_MAX
#if defined(_WIN32) && ! defined(__USE_MINGW_ANSI_STDIO)
#if defined(_WIN32) \
&& (! defined(__USE_MINGW_ANSI_STDIO) \
|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0))
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
@@ -156,7 +158,7 @@ void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
const char *unsignedCharToPrintable(unsigned char c);
# endif
#endif
#ifdef __cplusplus
}

View File

@@ -33,34 +33,34 @@
*/
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,

View File

@@ -99,14 +99,14 @@
#define SIPHASH_H
#include <stddef.h> /* size_t */
# include <stdint.h> /* uint64_t uint32_t uint8_t */
#include <stdint.h> /* uint64_t uint32_t uint8_t */
/*
* Workaround to not require a C++11 compiler for using ULL suffix
* 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))))

View File

@@ -33,34 +33,34 @@
*/
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,

View File

@@ -1,4 +1,4 @@
/* 8539b9040d9d901366a62560a064af7cb99811335784b363abc039c5b0ebc416 (2.4.1+)
/* 5ab094ffadd6edfc94c3eee53af44a86951f9f1f0933ada3114bbce2bfb02c99 (2.5.0+)
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
@@ -11,15 +11,15 @@
Copyright (c) 2000-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2009 Steven Solie <ssolie@users.sourceforge.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016 Eric Rahm <erahm@mozilla.com>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Gaurav <g.gupta@samsung.com>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2016 Gustavo Grieco <gustavo.grieco@imag.fr>
Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com>
Copyright (c) 2016 Ed Schouten <ed@nuxi.nl>
Copyright (c) 2017-2018 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017-2022 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Václav Slavík <vaclav@slavik.io>
Copyright (c) 2017 Viktor Szakats <commit@vsz.me>
Copyright (c) 2017 Chanho Park <chanho61.park@samsung.com>
@@ -32,6 +32,10 @@
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2019-2020 Ben Wagner <bungeman@chromium.org>
Copyright (c) 2019 Vadim Zeitlin <vadim@zeitlins.org>
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
Copyright (c) 2022 Samanta Navarro <ferivoz@riseup.net>
Copyright (c) 2022 Jeffrey Walton <noloader@gmail.com>
Copyright (c) 2022 Jann Horn <jannh@google.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -140,7 +144,7 @@
* BSD / macOS (including <10.7) (arc4random): HAVE_ARC4RANDOM, \
* libbsd (arc4random_buf): HAVE_ARC4RANDOM_BUF + HAVE_LIBBSD, \
* libbsd (arc4random): HAVE_ARC4RANDOM + HAVE_LIBBSD, \
* Linux (including <3.17) / BSD / macOS (including <10.7) (/dev/urandom): XML_DEV_URANDOM, \
* Linux (including <3.17) / BSD / macOS (including <10.7) / Solaris >=8 (/dev/urandom): XML_DEV_URANDOM, \
* Windows >=Vista (rand_s): _WIN32. \
\
If insist on not using any of these, bypass this error by defining \
@@ -725,11 +729,11 @@ XML_ParserCreate(const XML_Char *encodingName) {
XML_Parser XMLCALL
XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) {
XML_Char tmp[2];
*tmp = nsSep;
XML_Char tmp[2] = {nsSep, 0};
return XML_ParserCreate_MM(encodingName, NULL, tmp);
}
// "xml=http://www.w3.org/XML/1998/namespace"
static const XML_Char implicitContext[]
= {ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h,
ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH,
@@ -1085,6 +1089,14 @@ parserCreate(const XML_Char *encodingName,
parserInit(parser, encodingName);
if (encodingName && ! parser->m_protocolEncodingName) {
if (dtd) {
// We need to stop the upcoming call to XML_ParserFree from happily
// destroying parser->m_dtd because the DTD is shared with the parent
// parser and the only guard that keeps XML_ParserFree from destroying
// parser->m_dtd is parser->m_isParamEntity but it will be set to
// XML_TRUE only later in XML_ExternalEntityParserCreate (or not at all).
parser->m_dtd = NULL;
}
XML_ParserFree(parser);
return NULL;
}
@@ -1362,8 +1374,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
would be otherwise.
*/
if (parser->m_ns) {
XML_Char tmp[2];
*tmp = parser->m_namespaceSeparator;
XML_Char tmp[2] = {parser->m_namespaceSeparator, 0};
parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
} else {
parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
@@ -2086,6 +2097,11 @@ XML_GetBuffer(XML_Parser parser, int len) {
keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
if (keep > XML_CONTEXT_BYTES)
keep = XML_CONTEXT_BYTES;
/* Detect and prevent integer overflow */
if (keep > INT_MAX - neededSize) {
parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL;
}
neededSize += keep;
#endif /* defined XML_CONTEXT_BYTES */
if (neededSize
@@ -2502,29 +2518,29 @@ XML_GetFeatureList(void) {
{XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"),
sizeof(XML_LChar)},
#ifdef XML_UNICODE
{XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0},
{XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0},
#endif
#ifdef XML_UNICODE_WCHAR_T
{XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0},
{XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0},
#endif
#ifdef XML_DTD
{XML_FEATURE_DTD, XML_L("XML_DTD"), 0},
{XML_FEATURE_DTD, XML_L("XML_DTD"), 0},
#endif
#ifdef XML_CONTEXT_BYTES
{XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"),
XML_CONTEXT_BYTES},
{XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"),
XML_CONTEXT_BYTES},
#endif
#ifdef XML_MIN_SIZE
{XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0},
{XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0},
#endif
#ifdef XML_NS
{XML_FEATURE_NS, XML_L("XML_NS"), 0},
{XML_FEATURE_NS, XML_L("XML_NS"), 0},
#endif
#ifdef XML_LARGE_SIZE
{XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0},
{XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0},
#endif
#ifdef XML_ATTR_INFO
{XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0},
{XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0},
#endif
#ifdef XML_DTD
/* Added in Expat 2.4.0. */
@@ -2536,7 +2552,7 @@ XML_GetFeatureList(void) {
XML_L("XML_BLAP_ACT_THRES"),
EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT},
#endif
{XML_FEATURE_END, NULL, 0}};
{XML_FEATURE_END, NULL, 0}};
return features;
}
@@ -2576,6 +2592,7 @@ storeRawNames(XML_Parser parser) {
while (tag) {
int bufSize;
int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
size_t rawNameLen;
char *rawNameBuf = tag->buf + nameLen;
/* Stop if already stored. Since m_tagStack is a stack, we can stop
at the first entry that has already been copied; everything
@@ -2587,7 +2604,11 @@ storeRawNames(XML_Parser parser) {
/* For re-use purposes we need to ensure that the
size of tag->buf is a multiple of sizeof(XML_Char).
*/
bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
/* Detect and prevent integer overflow. */
if (rawNameLen > (size_t)INT_MAX - nameLen)
return XML_FALSE;
bufSize = nameLen + (int)rawNameLen;
if (bufSize > tag->bufEnd - tag->buf) {
char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
if (temp == NULL)
@@ -3019,9 +3040,6 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
int len;
const char *rawName;
TAG *tag = parser->m_tagStack;
parser->m_tagStack = tag->parent;
tag->parent = parser->m_freeTagList;
parser->m_freeTagList = tag;
rawName = s + enc->minBytesPerChar * 2;
len = XmlNameLength(enc, rawName);
if (len != tag->rawNameLength
@@ -3029,6 +3047,9 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
*eventPP = rawName;
return XML_ERROR_TAG_MISMATCH;
}
parser->m_tagStack = tag->parent;
tag->parent = parser->m_freeTagList;
parser->m_freeTagList = tag;
--parser->m_tagLevel;
if (parser->m_endElementHandler) {
const XML_Char *localPart;
@@ -3280,13 +3301,38 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
/* get the attributes from the tokenizer */
n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts);
/* Detect and prevent integer overflow */
if (n > INT_MAX - nDefaultAtts) {
return XML_ERROR_NO_MEMORY;
}
if (n + nDefaultAtts > parser->m_attsSize) {
int oldAttsSize = parser->m_attsSize;
ATTRIBUTE *temp;
#ifdef XML_ATTR_INFO
XML_AttrInfo *temp2;
#endif
/* Detect and prevent integer overflow */
if ((nDefaultAtts > INT_MAX - INIT_ATTS_SIZE)
|| (n > INT_MAX - (nDefaultAtts + INIT_ATTS_SIZE))) {
return XML_ERROR_NO_MEMORY;
}
parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(ATTRIBUTE)) {
parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY;
}
#endif
temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts,
parser->m_attsSize * sizeof(ATTRIBUTE));
if (temp == NULL) {
@@ -3295,6 +3341,17 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
}
parser->m_atts = temp;
#ifdef XML_ATTR_INFO
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
# if UINT_MAX >= SIZE_MAX
if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(XML_AttrInfo)) {
parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY;
}
# endif
temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo,
parser->m_attsSize * sizeof(XML_AttrInfo));
if (temp2 == NULL) {
@@ -3433,7 +3490,13 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
if (nPrefixes) {
int j; /* hash table index */
unsigned long version = parser->m_nsAttsVersion;
int nsAttsSize = (int)1 << parser->m_nsAttsPower;
/* Detect and prevent invalid shift */
if (parser->m_nsAttsPower >= sizeof(unsigned int) * 8 /* bits per byte */) {
return XML_ERROR_NO_MEMORY;
}
unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
unsigned char oldNsAttsPower = parser->m_nsAttsPower;
/* size of hash table must be at least 2 * (# of prefixed attributes) */
if ((nPrefixes << 1)
@@ -3444,7 +3507,28 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
;
if (parser->m_nsAttsPower < 3)
parser->m_nsAttsPower = 3;
nsAttsSize = (int)1 << parser->m_nsAttsPower;
/* Detect and prevent invalid shift */
if (parser->m_nsAttsPower >= sizeof(nsAttsSize) * 8 /* bits per byte */) {
/* Restore actual size of memory in m_nsAtts */
parser->m_nsAttsPower = oldNsAttsPower;
return XML_ERROR_NO_MEMORY;
}
nsAttsSize = 1u << parser->m_nsAttsPower;
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if (nsAttsSize > (size_t)(-1) / sizeof(NS_ATT)) {
/* Restore actual size of memory in m_nsAtts */
parser->m_nsAttsPower = oldNsAttsPower;
return XML_ERROR_NO_MEMORY;
}
#endif
temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts,
nsAttsSize * sizeof(NS_ATT));
if (! temp) {
@@ -3602,9 +3686,31 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
tagNamePtr->prefixLen = prefixLen;
for (i = 0; localPart[i++];)
; /* i includes null terminator */
/* Detect and prevent integer overflow */
if (binding->uriLen > INT_MAX - prefixLen
|| i > INT_MAX - (binding->uriLen + prefixLen)) {
return XML_ERROR_NO_MEMORY;
}
n = i + binding->uriLen + prefixLen;
if (n > binding->uriAlloc) {
TAG *p;
/* Detect and prevent integer overflow */
if (n > INT_MAX - EXPAND_SPARE) {
return XML_ERROR_NO_MEMORY;
}
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if ((unsigned)(n + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY;
}
#endif
uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char));
if (! uri)
return XML_ERROR_NO_MEMORY;
@@ -3629,12 +3735,124 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
return XML_ERROR_NONE;
}
static XML_Bool
is_rfc3986_uri_char(XML_Char candidate) {
// For the RFC 3986 ANBF grammar see
// https://datatracker.ietf.org/doc/html/rfc3986#appendix-A
switch (candidate) {
// From rule "ALPHA" (uppercase half)
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
// From rule "ALPHA" (lowercase half)
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
// From rule "DIGIT"
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
// From rule "pct-encoded"
case '%':
// From rule "unreserved"
case '-':
case '.':
case '_':
case '~':
// From rule "gen-delims"
case ':':
case '/':
case '?':
case '#':
case '[':
case ']':
case '@':
// From rule "sub-delims"
case '!':
case '$':
case '&':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case ';':
case '=':
return XML_TRUE;
default:
return XML_FALSE;
}
}
/* addBinding() overwrites the value of prefix->binding without checking.
Therefore one must keep track of the old value outside of addBinding().
*/
static enum XML_Error
addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
const XML_Char *uri, BINDING **bindingsPtr) {
// "http://www.w3.org/XML/1998/namespace"
static const XML_Char xmlNamespace[]
= {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON,
ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w,
@@ -3645,6 +3863,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c,
ASCII_e, '\0'};
static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1;
// "http://www.w3.org/2000/xmlns/"
static const XML_Char xmlnsNamespace[]
= {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH,
ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w,
@@ -3684,6 +3903,29 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
if (! mustBeXML && isXMLNS
&& (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
isXMLNS = XML_FALSE;
// NOTE: While Expat does not validate namespace URIs against RFC 3986
// today (and is not REQUIRED to do so with regard to the XML 1.0
// namespaces specification) we have to at least make sure, that
// the application on top of Expat (that is likely splitting expanded
// element names ("qualified names") of form
// "[uri sep] local [sep prefix] '\0'" back into 1, 2 or 3 pieces
// in its element handler code) cannot be confused by an attacker
// putting additional namespace separator characters into namespace
// declarations. That would be ambiguous and not to be expected.
//
// While the HTML API docs of function XML_ParserCreateNS have been
// advising against use of a namespace separator character that can
// appear in a URI for >20 years now, some widespread applications
// are using URI characters (':' (colon) in particular) for a
// namespace separator, in practice. To keep these applications
// functional, we only reject namespaces URIs containing the
// application-chosen namespace separator if the chosen separator
// is a non-URI character with regard to RFC 3986.
if (parser->m_ns && (uri[len] == parser->m_namespaceSeparator)
&& ! is_rfc3986_uri_char(uri[len])) {
return XML_ERROR_SYNTAX;
}
}
isXML = isXML && len == xmlLen;
isXMLNS = isXMLNS && len == xmlnsLen;
@@ -3700,6 +3942,21 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
if (parser->m_freeBindingList) {
b = parser->m_freeBindingList;
if (len > b->uriAlloc) {
/* Detect and prevent integer overflow */
if (len > INT_MAX - EXPAND_SPARE) {
return XML_ERROR_NO_MEMORY;
}
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY;
}
#endif
XML_Char *temp = (XML_Char *)REALLOC(
parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
if (temp == NULL)
@@ -3712,6 +3969,21 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
b = (BINDING *)MALLOC(parser, sizeof(BINDING));
if (! b)
return XML_ERROR_NO_MEMORY;
/* Detect and prevent integer overflow */
if (len > INT_MAX - EXPAND_SPARE) {
return XML_ERROR_NO_MEMORY;
}
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
return XML_ERROR_NO_MEMORY;
}
#endif
b->uri
= (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));
if (! b->uri) {
@@ -3996,7 +4268,7 @@ initializeEncoding(XML_Parser parser) {
const char *s;
#ifdef XML_UNICODE
char encodingBuf[128];
/* See comments abount `protoclEncodingName` in parserInit() */
/* See comments about `protocolEncodingName` in parserInit() */
if (! parser->m_protocolEncodingName)
s = NULL;
else {
@@ -4028,7 +4300,7 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s,
const XML_Char *storedEncName = NULL;
const ENCODING *newEncoding = NULL;
const char *version = NULL;
const char *versionend;
const char *versionend = NULL;
const XML_Char *storedversion = NULL;
int standalone = -1;
@@ -4732,10 +5004,10 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
parser->m_handlerArg, parser->m_declElementType->name,
parser->m_declAttributeId->name, parser->m_declAttributeType, 0,
role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
}
poolClear(&parser->m_tempPool);
break;
case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
@@ -5038,6 +5310,11 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
if (parser->m_prologState.level >= parser->m_groupSize) {
if (parser->m_groupSize) {
{
/* Detect and prevent integer overflow */
if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
return XML_ERROR_NO_MEMORY;
}
char *const new_connector = (char *)REALLOC(
parser, parser->m_groupConnector, parser->m_groupSize *= 2);
if (new_connector == NULL) {
@@ -5048,6 +5325,16 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
}
if (dtd->scaffIndex) {
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
return XML_ERROR_NO_MEMORY;
}
#endif
int *const new_scaff_index = (int *)REALLOC(
parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
if (new_scaff_index == NULL)
@@ -5128,7 +5415,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
*
* If 'standalone' is false, the DTD must have no
* parameter entities or we wouldn't have passed the outer
* 'if' statement. That measn the only entity in the hash
* 'if' statement. That means the only entity in the hash
* table is the external subset name "#" which cannot be
* given as a parameter entity name in XML syntax, so the
* lookup must have returned NULL and we don't even reach
@@ -5256,7 +5543,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
if (dtd->in_eldecl) {
ELEMENT_TYPE *el;
const XML_Char *name;
int nameLen;
size_t nameLen;
const char *nxt
= (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar);
int myindex = nextScaffoldPart(parser);
@@ -5272,7 +5559,13 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
nameLen = 0;
for (; name[nameLen++];)
;
dtd->contentStringLen += nameLen;
/* Detect and prevent integer overflow */
if (nameLen > UINT_MAX - dtd->contentStringLen) {
return XML_ERROR_NO_MEMORY;
}
dtd->contentStringLen += (unsigned)nameLen;
if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
}
@@ -5534,19 +5827,27 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
if (result != XML_ERROR_NONE)
return result;
else if (textEnd != next
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
entity->processed = (int)(next - (const char *)entity->textPtr);
return result;
} else {
}
#ifdef XML_DTD
entityTrackingOnClose(parser, entity, __LINE__);
entityTrackingOnClose(parser, entity, __LINE__);
#endif
entity->open = XML_FALSE;
parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
openEntity->next = parser->m_freeInternalEntities;
parser->m_freeInternalEntities = openEntity;
entity->open = XML_FALSE;
parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
openEntity->next = parser->m_freeInternalEntities;
parser->m_freeInternalEntities = openEntity;
// If there are more open entities we want to stop right here and have the
// upcoming call to XML_ResumeParser continue with entity content, or it would
// be ignored altogether.
if (parser->m_openInternalEntities != NULL
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
return XML_ERROR_NONE;
}
#ifdef XML_DTD
@@ -5562,10 +5863,15 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
{
parser->m_processor = contentProcessor;
/* see externalEntityContentProcessor vs contentProcessor */
return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding,
s, end, nextPtr,
(XML_Bool)! parser->m_parsingStatus.finalBuffer,
XML_ACCOUNT_DIRECT);
result = doContent(parser, parser->m_parentParser ? 1 : 0,
parser->m_encoding, s, end, nextPtr,
(XML_Bool)! parser->m_parsingStatus.finalBuffer,
XML_ACCOUNT_DIRECT);
if (result == XML_ERROR_NONE) {
if (! storeRawNames(parser))
return XML_ERROR_NO_MEMORY;
}
return result;
}
}
@@ -6118,7 +6424,24 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
}
} else {
DEFAULT_ATTRIBUTE *temp;
/* Detect and prevent integer overflow */
if (type->allocDefaultAtts > INT_MAX / 2) {
return 0;
}
int count = type->allocDefaultAtts * 2;
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if ((unsigned)count > (size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE)) {
return 0;
}
#endif
temp = (DEFAULT_ATTRIBUTE *)REALLOC(parser, type->defaultAtts,
(count * sizeof(DEFAULT_ATTRIBUTE)));
if (temp == NULL)
@@ -6581,8 +6904,8 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
if (! newE)
return 0;
if (oldE->nDefaultAtts) {
newE->defaultAtts = (DEFAULT_ATTRIBUTE *)ms->malloc_fcn(
oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
newE->defaultAtts = (DEFAULT_ATTRIBUTE *)
ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
if (! newE->defaultAtts) {
return 0;
}
@@ -6769,8 +7092,20 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) {
/* check for overflow (table is half full) */
if (table->used >> (table->power - 1)) {
unsigned char newPower = table->power + 1;
/* Detect and prevent invalid shift */
if (newPower >= sizeof(unsigned long) * 8 /* bits per byte */) {
return NULL;
}
size_t newSize = (size_t)1 << newPower;
unsigned long newMask = (unsigned long)newSize - 1;
/* Detect and prevent integer overflow */
if (newSize > (size_t)(-1) / sizeof(NAMED *)) {
return NULL;
}
size_t tsize = newSize * sizeof(NAMED *);
NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize);
if (! newV)
@@ -7120,6 +7455,20 @@ nextScaffoldPart(XML_Parser parser) {
if (dtd->scaffCount >= dtd->scaffSize) {
CONTENT_SCAFFOLD *temp;
if (dtd->scaffold) {
/* Detect and prevent integer overflow */
if (dtd->scaffSize > UINT_MAX / 2u) {
return -1;
}
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if (dtd->scaffSize > (size_t)(-1) / 2u / sizeof(CONTENT_SCAFFOLD)) {
return -1;
}
#endif
temp = (CONTENT_SCAFFOLD *)REALLOC(
parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
if (temp == NULL)
@@ -7151,55 +7500,130 @@ nextScaffoldPart(XML_Parser parser) {
return next;
}
static void
build_node(XML_Parser parser, int src_node, XML_Content *dest,
XML_Content **contpos, XML_Char **strpos) {
DTD *const dtd = parser->m_dtd; /* save one level of indirection */
dest->type = dtd->scaffold[src_node].type;
dest->quant = dtd->scaffold[src_node].quant;
if (dest->type == XML_CTYPE_NAME) {
const XML_Char *src;
dest->name = *strpos;
src = dtd->scaffold[src_node].name;
for (;;) {
*(*strpos)++ = *src;
if (! *src)
break;
src++;
}
dest->numchildren = 0;
dest->children = NULL;
} else {
unsigned int i;
int cn;
dest->numchildren = dtd->scaffold[src_node].childcnt;
dest->children = *contpos;
*contpos += dest->numchildren;
for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren;
i++, cn = dtd->scaffold[cn].nextsib) {
build_node(parser, cn, &(dest->children[i]), contpos, strpos);
}
dest->name = NULL;
}
}
static XML_Content *
build_model(XML_Parser parser) {
/* Function build_model transforms the existing parser->m_dtd->scaffold
* array of CONTENT_SCAFFOLD tree nodes into a new array of
* XML_Content tree nodes followed by a gapless list of zero-terminated
* strings. */
DTD *const dtd = parser->m_dtd; /* save one level of indirection */
XML_Content *ret;
XML_Content *cpos;
XML_Char *str;
int allocsize = (dtd->scaffCount * sizeof(XML_Content)
+ (dtd->contentStringLen * sizeof(XML_Char)));
XML_Char *str; /* the current string writing location */
/* Detect and prevent integer overflow.
* The preprocessor guard addresses the "always false" warning
* from -Wtype-limits on platforms where
* sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
if (dtd->scaffCount > (size_t)(-1) / sizeof(XML_Content)) {
return NULL;
}
if (dtd->contentStringLen > (size_t)(-1) / sizeof(XML_Char)) {
return NULL;
}
#endif
if (dtd->scaffCount * sizeof(XML_Content)
> (size_t)(-1) - dtd->contentStringLen * sizeof(XML_Char)) {
return NULL;
}
const size_t allocsize = (dtd->scaffCount * sizeof(XML_Content)
+ (dtd->contentStringLen * sizeof(XML_Char)));
ret = (XML_Content *)MALLOC(parser, allocsize);
if (! ret)
return NULL;
str = (XML_Char *)(&ret[dtd->scaffCount]);
cpos = &ret[1];
/* What follows is an iterative implementation (of what was previously done
* recursively in a dedicated function called "build_node". The old recursive
* build_node could be forced into stack exhaustion from input as small as a
* few megabyte, and so that was a security issue. Hence, a function call
* stack is avoided now by resolving recursion.)
*
* The iterative approach works as follows:
*
* - We have two writing pointers, both walking up the result array; one does
* the work, the other creates "jobs" for its colleague to do, and leads
* the way:
*
* - The faster one, pointer jobDest, always leads and writes "what job
* to do" by the other, once they reach that place in the
* array: leader "jobDest" stores the source node array index (relative
* to array dtd->scaffold) in field "numchildren".
*
* - The slower one, pointer dest, looks at the value stored in the
* "numchildren" field (which actually holds a source node array index
* at that time) and puts the real data from dtd->scaffold in.
*
* - Before the loop starts, jobDest writes source array index 0
* (where the root node is located) so that dest will have something to do
* when it starts operation.
*
* - Whenever nodes with children are encountered, jobDest appends
* them as new jobs, in order. As a result, tree node siblings are
* adjacent in the resulting array, for example:
*
* [0] root, has two children
* [1] first child of 0, has three children
* [3] first child of 1, does not have children
* [4] second child of 1, does not have children
* [5] third child of 1, does not have children
* [2] second child of 0, does not have children
*
* Or (the same data) presented in flat array view:
*
* [0] root, has two children
*
* [1] first child of 0, has three children
* [2] second child of 0, does not have children
*
* [3] first child of 1, does not have children
* [4] second child of 1, does not have children
* [5] third child of 1, does not have children
*
* - The algorithm repeats until all target array indices have been processed.
*/
XML_Content *dest = ret; /* tree node writing location, moves upwards */
XML_Content *const destLimit = &ret[dtd->scaffCount];
XML_Content *jobDest = ret; /* next free writing location in target array */
str = (XML_Char *)&ret[dtd->scaffCount];
/* Add the starting job, the root node (index 0) of the source tree */
(jobDest++)->numchildren = 0;
for (; dest < destLimit; dest++) {
/* Retrieve source tree array index from job storage */
const int src_node = (int)dest->numchildren;
/* Convert item */
dest->type = dtd->scaffold[src_node].type;
dest->quant = dtd->scaffold[src_node].quant;
if (dest->type == XML_CTYPE_NAME) {
const XML_Char *src;
dest->name = str;
src = dtd->scaffold[src_node].name;
for (;;) {
*str++ = *src;
if (! *src)
break;
src++;
}
dest->numchildren = 0;
dest->children = NULL;
} else {
unsigned int i;
int cn;
dest->name = NULL;
dest->numchildren = dtd->scaffold[src_node].childcnt;
dest->children = jobDest;
/* Append scaffold indices of children to array */
for (i = 0, cn = dtd->scaffold[src_node].firstchild;
i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib)
(jobDest++)->numchildren = (unsigned int)cn;
}
}
build_node(parser, 0, ret, &cpos, &str);
return ret;
}
@@ -7228,7 +7652,7 @@ getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr,
static XML_Char *
copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {
int charsRequired = 0;
size_t charsRequired = 0;
XML_Char *result;
/* First determine how long the string is */

View File

@@ -11,10 +11,11 @@
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
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 <ssolie@users.sourceforge.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2021 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>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@@ -11,8 +11,8 @@
Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2009 Steven Solie <ssolie@users.sourceforge.net>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2022 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,6 +20,8 @@
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) 2022 Martin Ettl <ettl.martin78@googlemail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -48,7 +50,7 @@
#ifdef EXPAT_WIN32
# include "winconfig.h"
#endif
#endif
#include "expat_config.h"
@@ -97,11 +99,6 @@
+ ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
& (1u << (((byte)[2]) & 0x1F)))
#define UTF8_GET_NAMING(pages, p, n) \
((n) == 2 \
? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
: ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0))
/* Detection of invalid UTF-8 sequences is based on Table 3.1B
of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
with the additional restriction of not allowing the Unicode
@@ -276,8 +273,8 @@ sb_byteToAscii(const ENCODING *enc, const char *p) {
(AS_NORMAL_ENCODING(enc)->isInvalid##n \
&& AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#else
#define IS_INVALID_CHAR(enc, p, n) \
(AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
# define IS_INVALID_CHAR(enc, p, n) \
(AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#endif
#ifdef XML_MIN_SIZE
@@ -300,7 +297,7 @@ sb_charMatches(const ENCODING *enc, const char *p, int c) {
}
#else
/* c is an ASCII character */
# define CHAR_MATCHES(enc, p, c) (*(p) == c)
# define CHAR_MATCHES(enc, p, c) (*(p) == (c))
#endif
#define PREFIX(ident) normal_##ident
@@ -744,7 +741,7 @@ DEFINE_UTF16_TO_UTF16(big2_)
((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(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_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == (c))
#define LITTLE2_IS_NAME_CHAR_MINBPC(p) \
UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) \
@@ -879,7 +876,7 @@ static const struct normal_encoding internal_little2_encoding
? ((struct normal_encoding *)(enc))->type[(unsigned char)(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_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == (c))
#define BIG2_IS_NAME_CHAR_MINBPC(p) \
UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
#define BIG2_IS_NMSTRT_CHAR_MINBPC(p) \

View File

@@ -10,12 +10,13 @@
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Benjamin Peterson <benjamin@python.org>
Copyright (c) 2018 Anton Maklakov <antmak.pub@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2020 Boris Kolpackov <boris@codesynthesis.com>
Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -69,7 +70,7 @@
case BT_LEAD##n: \
if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \
if (! IS_NAME_CHAR(enc, ptr, n)) { \
if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
@@ -96,9 +97,9 @@
# define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
case BT_LEAD##n: \
if (end - ptr < n) \
if ((end) - (ptr) < (n)) \
return XML_TOK_PARTIAL_CHAR; \
if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \
if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
@@ -124,7 +125,8 @@
# define PREFIX(ident) ident
# endif
# define HAS_CHARS(enc, ptr, end, count) (end - ptr >= count * MINBPC(enc))
# define HAS_CHARS(enc, ptr, end, count) \
((end) - (ptr) >= ((count)*MINBPC(enc)))
# define HAS_CHAR(enc, ptr, end) HAS_CHARS(enc, ptr, end, 1)
@@ -1142,6 +1144,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_LEAD##n: \
if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \
if (IS_INVALID_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
ptr += n; \
tok = XML_TOK_NAME; \
@@ -1270,7 +1276,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1339,7 +1345,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1518,7 +1524,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
state = inName; \
}
# define LEAD_CASE(n) \
case BT_LEAD##n: \
case BT_LEAD##n: /* NOTE: The encoding has already been validated. */ \
START_NAME ptr += (n - MINBPC(enc)); \
break;
LEAD_CASE(2)
@@ -1730,7 +1736,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) {
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1775,7 +1781,7 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
pos->columnNumber++; \
break;
LEAD_CASE(2)

View File

@@ -45,7 +45,7 @@ enum {
BT_LF, /* line feed = "\n" */
BT_GT, /* greater than = ">" */
BT_QUOT, /* quotation character = "\"" */
BT_APOS, /* aposthrophe = "'" */
BT_APOS, /* apostrophe = "'" */
BT_EQUALS, /* equal sign = "=" */
BT_QUEST, /* question mark = "?" */
BT_EXCL, /* exclamation mark = "!" */

View File

@@ -11,7 +11,7 @@
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -93,7 +93,7 @@ NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
static const ENCODING *
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
# define ENCODING_MAX 128
char buf[ENCODING_MAX];
char buf[ENCODING_MAX] = "";
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);