1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 23:27:15 +02:00

Update POCO to 1.11.0

This commit is contained in:
Sandu Liviu Catalin
2021-08-22 18:07:06 +03:00
parent 151077c799
commit 7a3d92d1d1
450 changed files with 25219 additions and 6528 deletions

View File

@ -52,8 +52,8 @@ protected:
void dispatchNodeRemovedFromDocument();
void dispatchNodeInsertedIntoDocument();
static const Node* findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap);
static const Node* findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap, bool& indexBound);
static const Node* findElement(const XMLString& name, const Node* pNode, const NSMap* pNSMap);
static const Node* findElement(int index, const Node* pNode, const NSMap* pNSMap);
static const Node* findElement(const XMLString& attr, const XMLString& value, const Node* pNode, const NSMap* pNSMap);

View File

@ -28,7 +28,7 @@ namespace XML {
class XML_API SAXParser: public XMLReader
/// This class provides a SAX2 (Simple API for XML) interface to expat,
/// This class provides a SAX2 (Simple API for XML) interface to expat,
/// the XML parser toolkit.
/// The following SAX2 features and properties are supported:
/// * http://xml.org/sax/features/external-general-entities
@ -41,6 +41,14 @@ class XML_API SAXParser: public XMLReader
/// The following proprietary extensions are supported:
/// * http://www.appinf.com/features/enable-partial-reads --
/// see ParserEngine::setEnablePartialReads()
/// * http://www.appinf.com/properties/bla-maximum-amplification
/// see ParserEngine::setBillionLaughsAttackProtectionMaximumAmplification();
/// argument must be a float >= 1.0 formatted as string;
/// property is set-only.
/// * http://www.appinf.com/properties/bla-activation-threshold
/// see ParserEngine::setBillionLaughsAttackProtectionActivationThreshold();
/// argument must be a 64-bit unsigned integer formatted as string;
/// property is set-only.
{
public:
SAXParser();
@ -48,14 +56,14 @@ public:
SAXParser(const XMLString& encoding);
/// Creates an SAXParser with the given encoding.
~SAXParser();
/// Destroys the SAXParser.
void setEncoding(const XMLString& encoding);
/// Sets the encoding used by the parser if no
/// encoding is specified in the XML document.
const XMLString& getEncoding() const;
/// Returns the name of the encoding used by
/// the parser if no encoding is specified in
@ -81,11 +89,13 @@ public:
void parse(InputSource* pSource);
void parse(const XMLString& systemId);
void parseMemoryNP(const char* xml, std::size_t size);
/// Extensions
void parseString(const std::string& xml);
static const XMLString FEATURE_PARTIAL_READS;
static const XMLString PROPERTY_BLA_MAXIMUM_AMPLIFICATION;
static const XMLString PROPERTY_BLA_ACTIVATION_THRESHOLD;
protected:
void setupParse();

View File

@ -47,28 +47,28 @@ class ContextLocator;
class XML_API ParserEngine: public Locator
/// This class provides an object-oriented, stream-based,
/// 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
/// 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.
@ -80,33 +80,33 @@ public:
/// 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
/// 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.
@ -121,7 +121,7 @@ public:
void setDeclHandler(DeclHandler* pDeclHandler);
/// Allow an application to register a DTD declarations event handler.
DeclHandler* getDeclHandler() const;
/// Return the current DTD declarations handler.
@ -133,7 +133,7 @@ public:
void setLexicalHandler(LexicalHandler* pLexicalHandler);
/// Allow an application to register a lexical event handler.
LexicalHandler* getLexicalHandler() const;
/// Return the current lexical handler.
@ -142,12 +142,12 @@ public:
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
/// 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.
@ -158,21 +158,44 @@ public:
/// 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.
@ -180,7 +203,7 @@ public:
/// Return the line number where the current document event ends.
int getColumnNumber() const;
/// Return the column number where the current document event ends.
/// Return the column number where the current document event ends.
protected:
void init();
@ -191,7 +214,7 @@ protected:
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.
@ -213,10 +236,10 @@ protected:
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.
@ -240,7 +263,7 @@ protected:
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,
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);
@ -248,14 +271,14 @@ protected:
// 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;
bool _encodingSpecified;
XMLString _encoding;
bool _expandInternalEntities;
bool _externalGeneralEntities;
@ -264,14 +287,17 @@ private:
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;
};

View File

@ -7,7 +7,14 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2005 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) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -115,7 +122,11 @@ enum XML_Error {
XML_ERROR_RESERVED_PREFIX_XMLNS,
XML_ERROR_RESERVED_NAMESPACE_URI,
/* Added in 2.2.1. */
XML_ERROR_INVALID_ARGUMENT
XML_ERROR_INVALID_ARGUMENT,
/* Added in 2.3.0. */
XML_ERROR_NO_BUFFER,
/* Added in 2.4.0. */
XML_ERROR_AMPLIFICATION_LIMIT_BREACH
};
enum XML_Content_Type {
@ -318,7 +329,7 @@ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
For internal entities (<!ENTITY foo "bar">), value will
be non-NULL and systemId, publicID, and notationName will be NULL.
The value string is NOT nul-terminated; the length is provided in
The value string is NOT null-terminated; the length is provided in
the value_length argument. Since it is legal to have zero-length
values, do not use this argument to test for internal entities.
@ -513,7 +524,7 @@ typedef struct {
Otherwise it must return XML_STATUS_ERROR.
If info does not describe a suitable encoding, then the parser will
return an XML_UNKNOWN_ENCODING error.
return an XML_ERROR_UNKNOWN_ENCODING error.
*/
typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
const XML_Char *name,
@ -707,7 +718,7 @@ XML_GetBase(XML_Parser parser);
/* Returns the number of the attribute/value pairs passed in last call
to the XML_StartElementHandler that were specified in the start-tag
rather than defaulted. Each attribute/value pair counts as 2; thus
this correspondds to an index into the atts array passed to the
this corresponds to an index into the atts array passed to the
XML_StartElementHandler. Returns -1 if parser == NULL.
*/
XMLPARSEAPI(int)
@ -716,7 +727,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
/* Returns the index of the ID attribute passed in the last call to
XML_StartElementHandler, or -1 if there is no ID attribute or
parser == NULL. Each attribute/value pair counts as 2; thus this
correspondds to an index into the atts array passed to the
corresponds to an index into the atts array passed to the
XML_StartElementHandler.
*/
XMLPARSEAPI(int)
@ -997,7 +1008,10 @@ enum XML_FeatureEnum {
XML_FEATURE_SIZEOF_XML_LCHAR,
XML_FEATURE_NS,
XML_FEATURE_LARGE_SIZE,
XML_FEATURE_ATTR_INFO
XML_FEATURE_ATTR_INFO,
/* Added in Expat 2.4.0. */
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
/* Additional features must be added to the end of this enum. */
};
@ -1010,12 +1024,24 @@ typedef struct {
XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void);
#ifdef XML_DTD
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
XML_Parser parser, float maximumAmplificationFactor);
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionActivationThreshold(
XML_Parser parser, unsigned long long activationThresholdBytes);
#endif
/* Expat follows the semantic versioning convention.
See http://semver.org.
*/
#define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 2
#define XML_MICRO_VERSION 8
#define XML_MINOR_VERSION 4
#define XML_MICRO_VERSION 1
#ifdef __cplusplus
}

View File

@ -7,7 +7,14 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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

View File

@ -30,14 +30,14 @@ namespace XML {
const XMLString AbstractContainerNode::WILDCARD(toXMLString("*"));
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument):
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument):
AbstractNode(pOwnerDocument),
_pFirstChild(0)
{
}
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node):
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node):
AbstractNode(pOwnerDocument, node),
_pFirstChild(0)
{
@ -199,7 +199,7 @@ Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild)
AbstractNode* pCur = _pFirstChild;
while (pCur && pCur->_pNext != oldChild) pCur = pCur->_pNext;
if (pCur)
{
{
poco_assert_dbg (pCur->_pNext == oldChild);
if (doEvents)
@ -311,8 +311,9 @@ bool AbstractContainerNode::hasAttributes() const
Node* AbstractContainerNode::getNodeByPath(const XMLString& path) const
{
bool indexBound;
XMLString::const_iterator it = path.begin();
if (it != path.end() && *it == '/')
if (it != path.end() && *it == '/')
{
++it;
if (it != path.end() && *it == '/')
@ -327,20 +328,21 @@ Node* AbstractContainerNode::getNodeByPath(const XMLString& path) const
for (unsigned long i = 0; i < length; i++)
{
XMLString::const_iterator beg = it;
const Node* pNode = findNode(beg, path.end(), pList->item(i), 0);
const Node* pNode = findNode(beg, path.end(), pList->item(i), 0, indexBound);
if (pNode) return const_cast<Node*>(pNode);
}
return 0;
}
}
return const_cast<Node*>(findNode(it, path.end(), this, 0));
return const_cast<Node*>(findNode(it, path.end(), this, 0, indexBound));
}
Node* AbstractContainerNode::getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const
{
bool indexBound;
XMLString::const_iterator it = path.begin();
if (it != path.end() && *it == '/')
if (it != path.end() && *it == '/')
{
++it;
if (it != path.end() && *it == '/')
@ -368,19 +370,20 @@ Node* AbstractContainerNode::getNodeByPathNS(const XMLString& path, const NSMap&
for (unsigned long i = 0; i < length; i++)
{
XMLString::const_iterator beg = it;
const Node* pNode = findNode(beg, path.end(), pList->item(i), &nsMap);
const Node* pNode = findNode(beg, path.end(), pList->item(i), &nsMap, indexBound);
if (pNode) return const_cast<Node*>(pNode);
}
}
return 0;
}
}
return const_cast<Node*>(findNode(it, path.end(), this, &nsMap));
return const_cast<Node*>(findNode(it, path.end(), this, &nsMap, indexBound));
}
const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap)
const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap, bool& indexBound)
{
indexBound = false;
if (pNode && it != end)
{
if (*it == '[')
@ -406,7 +409,8 @@ const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const
while (it != end && *it != ']') value += *it++;
}
if (it != end) ++it;
return findNode(it, end, findElement(attr, value, pNode, pNSMap), pNSMap);
bool ib;
return findNode(it, end, findElement(attr, value, pNode, pNSMap), pNSMap, ib);
}
else
{
@ -416,17 +420,19 @@ const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const
}
else
{
XMLString index;
while (it != end && *it != ']') index += *it++;
XMLString xmlIndex;
while (it != end && *it != ']') xmlIndex += *it++;
if (it != end) ++it;
#ifdef XML_UNICODE_WCHAR_T
std::string idx;
Poco::UnicodeConverter::convert(index, idx);
int i = Poco::NumberParser::parse(idx);
#else
std::string index;
Poco::UnicodeConverter::convert(xmlIndex, index);
int i = Poco::NumberParser::parse(index);
#else
int i = Poco::NumberParser::parse(xmlIndex);
#endif
return findNode(it, end, findElement(i, pNode, pNSMap), pNSMap);
indexBound = true;
bool ib;
return findNode(it, end, findElement(i, pNode, pNSMap), pNSMap, ib);
}
}
else
@ -440,8 +446,9 @@ const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const
const Node* pElem = findElement(key, pNode->firstChild(), pNSMap);
while (!pFound && pElem)
{
pFound = findNode(it, end, pElem, pNSMap);
if (!pFound) pElem = findElement(key, pElem->nextSibling(), pNSMap);
bool ib;
pFound = findNode(it, end, pElem, pNSMap, ib);
if (!pFound) pElem = ib ? nullptr : findElement(key, pElem->nextSibling(), pNSMap);
it = itStart;
}
return pFound;

View File

@ -47,16 +47,16 @@ public:
_systemId(systemId)
{
}
~ContextLocator()
{
}
XMLString getPublicId() const
{
return _publicId;
}
XMLString getSystemId() const
{
return _systemId;
@ -66,12 +66,12 @@ public:
{
return XML_GetCurrentLineNumber(_parser);
}
int getColumnNumber() const
{
return XML_GetCurrentColumnNumber(_parser);
}
private:
XML_Parser _parser;
XMLString _publicId;
@ -97,7 +97,9 @@ ParserEngine::ParserEngine():
_pDeclHandler(0),
_pContentHandler(0),
_pLexicalHandler(0),
_pErrorHandler(0)
_pErrorHandler(0),
_maximumAmplificationFactor(0.0),
_activationThresholdBytes(0)
{
}
@ -117,7 +119,9 @@ ParserEngine::ParserEngine(const XMLString& encoding):
_pDeclHandler(0),
_pContentHandler(0),
_pLexicalHandler(0),
_pErrorHandler(0)
_pErrorHandler(0),
_maximumAmplificationFactor(0.0),
_activationThresholdBytes(0)
{
}
@ -145,14 +149,14 @@ void ParserEngine::addEncoding(const XMLString& name, TextEncoding* pEncoding)
if (_encodings.find(name) == _encodings.end())
_encodings[name] = pEncoding;
else
throw XMLException("Encoding already defined");
throw XMLException("Encoding already defined");
}
void ParserEngine::setNamespaceStrategy(NamespaceStrategy* pStrategy)
{
poco_check_ptr (pStrategy);
delete _pNamespaceStrategy;
_pNamespaceStrategy = pStrategy;
}
@ -218,6 +222,18 @@ void ParserEngine::setEnablePartialReads(bool flag)
}
void ParserEngine::setBillionLaughsAttackProtectionMaximumAmplification(float maximumAmplificationFactor)
{
_maximumAmplificationFactor = maximumAmplificationFactor;
}
void ParserEngine::setBillionLaughsAttackProtectionActivationThreshold(Poco::UInt64 activationThresholdBytes)
{
_activationThresholdBytes = activationThresholdBytes;
}
void ParserEngine::parse(InputSource* pInputSource)
{
init();
@ -267,7 +283,7 @@ void ParserEngine::parseByteInputStream(XMLByteInputStream& istr)
handleError(XML_GetErrorCode(_parser));
if (istr.good())
n = readBytes(istr, _pBuffer, PARSE_BUFFER_SIZE);
else
else
n = 0;
}
if (!XML_Parse(_parser, _pBuffer, 0, 1))
@ -284,7 +300,7 @@ void ParserEngine::parseCharInputStream(XMLCharInputStream& istr)
handleError(XML_GetErrorCode(_parser));
if (istr.good())
n = readChars(istr, reinterpret_cast<XMLChar*>(_pBuffer), PARSE_BUFFER_SIZE/sizeof(XMLChar));
else
else
n = 0;
}
if (!XML_Parse(_parser, _pBuffer, 0, 1))
@ -316,7 +332,7 @@ void ParserEngine::parseExternalByteInputStream(XML_Parser extParser, XMLByteInp
handleError(XML_GetErrorCode(extParser));
if (istr.good())
n = readBytes(istr, pBuffer, PARSE_BUFFER_SIZE);
else
else
n = 0;
}
if (!XML_Parse(extParser, pBuffer, 0, 1))
@ -343,7 +359,7 @@ void ParserEngine::parseExternalCharInputStream(XML_Parser extParser, XMLCharInp
handleError(XML_GetErrorCode(extParser));
if (istr.good())
n = readChars(istr, pBuffer, static_cast<int>(PARSE_BUFFER_SIZE/sizeof(XMLChar)));
else
else
n = 0;
}
if (!XML_Parse(extParser, reinterpret_cast<char*>(pBuffer), 0, 1))
@ -487,6 +503,17 @@ void ParserEngine::init()
XML_SetSkippedEntityHandler(_parser, handleSkippedEntity);
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 (_maximumAmplificationFactor > 1.0)
{
XML_SetBillionLaughsAttackProtectionMaximumAmplification(_parser, _maximumAmplificationFactor);
}
if (_activationThresholdBytes > 0)
{
XML_SetBillionLaughsAttackProtectionActivationThreshold(_parser, _activationThresholdBytes);
}
#endif
}
@ -541,7 +568,7 @@ void ParserEngine::handleError(int errorNo)
case XML_ERROR_NOT_STANDALONE:
throw SAXParseException("Document is not standalone", locator());
case XML_ERROR_UNEXPECTED_STATE:
throw SAXParseException("Unexpected parser state - please send a bug report", locator());
throw SAXParseException("Unexpected parser state - please send a bug report", locator());
case XML_ERROR_ENTITY_DECLARED_IN_PE:
throw SAXParseException("Entity declared in parameter entity", locator());
case XML_ERROR_FEATURE_REQUIRES_XML_DTD:
@ -570,6 +597,26 @@ void ParserEngine::handleError(int errorNo)
throw SAXParseException("Parsing finished", locator());
case XML_ERROR_SUSPEND_PE:
throw SAXParseException("Cannot suspend in external parameter entity", locator());
#if XML_MAJOR_VERSION >= 2
case XML_ERROR_RESERVED_PREFIX_XML:
throw SAXParseException("Reserved prefix 'xml' must not be undeclared or bound to another namespace name", locator());
case XML_ERROR_RESERVED_PREFIX_XMLNS:
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
case XML_ERROR_INVALID_ARGUMENT:
throw SAXParseException("Invalid argument", locator());
#endif
#if XML_MAJOR_VERSION > 2 || XML_MINOR_VERSION >= 3
case XML_ERROR_NO_BUFFER:
throw SAXParseException("Internal error: a successful prior call to function XML_GetBuffer is required", locator());
#endif
#if XML_MAJOR_VERSION > 2 || XML_MINOR_VERSION >= 4
case XML_ERROR_AMPLIFICATION_LIMIT_BREACH:
throw SAXParseException("Limit on input amplification factor (from DTD and entities) breached", locator());
#endif
#endif // XML_MAJOR_VERSION
}
throw XMLException("Unknown Expat error code");
}
@ -583,7 +630,7 @@ void ParserEngine::handleError(int errorNo)
if (_pErrorHandler) _pErrorHandler->fatalError(SAXParseException("Fatal error", locator(), exc));
throw;
}
}
}
void ParserEngine::pushContext(XML_Parser parser, InputSource* pInputSource)
@ -614,12 +661,12 @@ void ParserEngine::resetContext()
void ParserEngine::handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
{
try
{
pThis->_pNamespaceStrategy->startElement(name, atts, XML_GetSpecifiedAttributeCount(pThis->_parser)/2, pThis->_pContentHandler);
pThis->_pNamespaceStrategy->startElement(name, atts, XML_GetSpecifiedAttributeCount(pThis->_parser)/2, pThis->_pContentHandler);
}
catch (XMLException& exc)
{
@ -632,12 +679,12 @@ void ParserEngine::handleStartElement(void* userData, const XML_Char* name, cons
void ParserEngine::handleEndElement(void* userData, const XML_Char* name)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
{
try
{
pThis->_pNamespaceStrategy->endElement(name, pThis->_pContentHandler);
pThis->_pNamespaceStrategy->endElement(name, pThis->_pContentHandler);
}
catch (XMLException& exc)
{
@ -650,7 +697,7 @@ void ParserEngine::handleEndElement(void* userData, const XML_Char* name)
void ParserEngine::handleCharacterData(void* userData, const XML_Char* s, int len)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->characters(s, 0, len);
}
@ -659,7 +706,7 @@ void ParserEngine::handleCharacterData(void* userData, const XML_Char* s, int le
void ParserEngine::handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->processingInstruction(target, data);
}
@ -673,10 +720,10 @@ void ParserEngine::handleDefault(void* userData, const XML_Char* s, int len)
void ParserEngine::handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString pubId;
if (publicId) pubId.assign(publicId);
if (pThis->_pDTDHandler)
if (pThis->_pDTDHandler)
pThis->_pDTDHandler->unparsedEntityDecl(entityName, publicId ? &pubId : 0, systemId, notationName);
}
@ -684,12 +731,12 @@ void ParserEngine::handleUnparsedEntityDecl(void* userData, const XML_Char* enti
void ParserEngine::handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString pubId;
if (publicId) pubId.assign(publicId);
XMLString sysId;
if (systemId) sysId.assign(systemId);
if (pThis->_pDTDHandler)
if (pThis->_pDTDHandler)
pThis->_pDTDHandler->notationDecl(notationName, publicId ? &pubId : 0, systemId ? &sysId : 0);
}
@ -708,7 +755,7 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con
XMLString sysId(systemId);
XMLString pubId;
if (publicId) pubId.assign(publicId);
URI uri(fromXMLString(pThis->_context.back()->getSystemId()));
uri.resolve(fromXMLString(sysId));
@ -749,7 +796,7 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con
int ParserEngine::handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(encodingHandlerData);
XMLString encoding(name);
TextEncoding* knownEncoding = 0;
@ -764,7 +811,7 @@ int ParserEngine::handleUnknownEncoding(void* encodingHandlerData, const XML_Cha
const TextEncoding::CharacterMap& map = knownEncoding->characterMap();
for (int i = 0; i < 256; ++i)
info->map[i] = map[i];
info->data = knownEncoding;
info->convert = &ParserEngine::convert;
info->release = 0;
@ -846,7 +893,7 @@ void ParserEngine::handleEndDoctypeDecl(void* userData)
}
void ParserEngine::handleEntityDecl(void *userData, const XML_Char *entityName, int isParamEntity, const XML_Char *value, int valueLength,
void ParserEngine::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)
{
if (value)
@ -880,7 +927,7 @@ void ParserEngine::handleInternalParsedEntityDecl(void* userData, const XML_Char
void ParserEngine::handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->skippedEntity(entityName);
}

View File

@ -17,6 +17,7 @@
#include "Poco/SAX/EntityResolverImpl.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/XML/NamespaceStrategy.h"
#include "Poco/NumberParser.h"
#include <sstream>
@ -25,6 +26,8 @@ namespace XML {
const XMLString SAXParser::FEATURE_PARTIAL_READS = toXMLString("http://www.appinf.com/features/enable-partial-reads");
const XMLString SAXParser::PROPERTY_BLA_MAXIMUM_AMPLIFICATION = toXMLString("http://www.appinf.com/properties/bla-maximum-amplification");
const XMLString SAXParser::PROPERTY_BLA_ACTIVATION_THRESHOLD = toXMLString("http://www.appinf.com/properties/bla-activation-threshold");
SAXParser::SAXParser():
@ -52,7 +55,7 @@ void SAXParser::setEncoding(const XMLString& encoding)
_engine.setEncoding(encoding);
}
const XMLString& SAXParser::getEncoding() const
{
return _engine.getEncoding();
@ -153,6 +156,10 @@ 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)));
else if (propertyId == PROPERTY_BLA_ACTIVATION_THRESHOLD)
_engine.setBillionLaughsAttackProtectionActivationThreshold(Poco::NumberParser::parseUnsigned64(value));
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}

View File

@ -6,8 +6,11 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2007 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -31,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

@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -32,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

@ -25,8 +25,12 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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) 2018 Yury Gribov <tetra2005@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -101,22 +105,58 @@
# endif
#endif
#include <limits.h> // ULONG_MAX
#if defined(_WIN32) && ! defined(__USE_MINGW_ANSI_STDIO)
# 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"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
# else
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif
#else
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
# if ! defined(ULONG_MAX)
# error Compiler did not define ULONG_MAX for us
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
# else
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif
#endif
#ifndef UNUSED_P
# define UNUSED_P(p) (void)p
#endif
/* NOTE BEGIN If you ever patch these defaults to greater values
for non-attack XML payload in your environment,
please file a bug report with libexpat. Thank you!
*/
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
100.0f
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
8388608 // 8 MiB, 2^23
/* NOTE END */
#include "Poco/XML/expat.h" // so we can use type XML_Parser below
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_ENABLE_VISIBILITY
# if XML_ENABLE_VISIBILITY
__attribute__((visibility("default")))
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
#if defined(XML_DTD)
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
const char *unsignedCharToPrintable(unsigned char c);
# endif
#endif
void
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
#ifdef __cplusplus
}

View File

@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -31,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

@ -6,8 +6,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -11,6 +11,9 @@
* --------------------------------------------------------------------------
* HISTORY:
*
* 2020-10-03 (Sebastian Pipping)
* - Drop support for Visual Studio 9.0/2008 and earlier
*
* 2019-08-03 (Sebastian Pipping)
* - Mark part of sip24_valid as to be excluded from clang-format
* - Re-format code using clang-format 9
@ -96,15 +99,7 @@
#define SIPHASH_H
#include <stddef.h> /* size_t */
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h> /* uint64_t uint32_t uint8_t */
#endif
/*
* Workaround to not require a C++11 compiler for using ULL suffix

View File

@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -31,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,

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,14 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
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) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -34,11 +41,9 @@
#ifdef EXPAT_WIN32
#include "winconfig.h"
#else
#ifdef HAVE_EXPAT_CONFIG_H
#include "expat_config.h"
#endif
#endif /* ndef EXPAT_WIN32 */
#include "expat_config.h"
#include "Poco/XML/expat_external.h"
#include "internal.h"
@ -1220,6 +1225,8 @@ common(PROLOG_STATE *state, int tok) {
#ifdef XML_DTD
if (! state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
return XML_ROLE_INNER_PARAM_ENTITY_REF;
#else
UNUSED_P(tok);
#endif
state->handler = error;
return XML_ROLE_ERROR;

View File

@ -7,7 +7,10 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -33,6 +36,12 @@
#ifndef XmlRole_INCLUDED
#define XmlRole_INCLUDED 1
#ifdef __VMS
/* 0 1 2 3 0 1 2 3
1234567890123456789012345678901 1234567890123456789012345678901 */
# define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
#endif
#include "xmltok.h"
#ifdef __cplusplus

View File

@ -7,7 +7,19 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
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) 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>
Copyright (c) 2017 Alexander Bluhm <alexander.bluhm@gmx.net>
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>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -32,23 +44,13 @@
#include <stddef.h>
#include <string.h> /* memcpy */
#if defined(_MSC_VER) && (_MSC_VER <= 1700)
/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
# define bool int
# define false 0
# define true 1
#else
# include <stdbool.h>
#endif
#include <stdbool.h>
#ifdef EXPAT_WIN32
# include "winconfig.h"
#else
# ifdef HAVE_EXPAT_CONFIG_H
# include "expat_config.h"
# endif
#endif /* ndef _WIN32 */
#endif
#include "expat_config.h"
#include "Poco/XML/expat_external.h"
#include "internal.h"
@ -269,8 +271,14 @@ sb_byteToAscii(const ENCODING *enc, const char *p) {
#define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))
#define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))
#ifdef XML_MIN_SIZE
# define IS_INVALID_CHAR(enc, p, n) \
(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))
#endif
#ifdef XML_MIN_SIZE
# define IS_NAME_CHAR_MINBPC(enc, p) \
@ -589,13 +597,13 @@ static const struct normal_encoding ascii_encoding
static int PTRFASTCALL
unicode_byte_type(char hi, char lo) {
switch ((unsigned char)hi) {
/* 0xD8000xDBFF first 16-bit code unit or high surrogate (W1) */
/* 0xD800-0xDBFF first 16-bit code unit or high surrogate (W1) */
case 0xD8:
case 0xD9:
case 0xDA:
case 0xDB:
return BT_LEAD4;
/* 0xDC000xDFFF second 16-bit code unit or low surrogate (W2) */
/* 0xDC00-0xDFFF second 16-bit code unit or low surrogate (W2) */
case 0xDC:
case 0xDD:
case 0xDE:

View File

@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -1,4 +1,4 @@
/* This file is included!
/* This file is included (from xmltok.c, 1-3 times depending on XML_MIN_SIZE)!
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
@ -7,7 +7,15 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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) 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>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@ -32,7 +40,7 @@
#ifdef XML_TOK_IMPL_C
# ifndef IS_INVALID_CHAR
# ifndef IS_INVALID_CHAR // i.e. for UTF-16 and XML_MIN_SIZE not defined
# define IS_INVALID_CHAR(enc, ptr, n) (0)
# endif
@ -1768,13 +1776,14 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
pos->columnNumber++; \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE
case BT_LF:
pos->columnNumber = (XML_Size)-1;
pos->columnNumber = 0;
pos->lineNumber++;
ptr += MINBPC(enc);
break;
@ -1783,13 +1792,13 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc);
if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF)
ptr += MINBPC(enc);
pos->columnNumber = (XML_Size)-1;
pos->columnNumber = 0;
break;
default:
ptr += MINBPC(enc);
pos->columnNumber++;
break;
}
pos->columnNumber++;
}
}

View File

@ -7,7 +7,8 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017-2019 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
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>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -45,15 +45,15 @@ void ElementTest::testAttributes()
{
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pElem = pDoc->createElement("elem");
assertTrue (!pElem->hasAttributes());
pElem->setAttribute("a1", "v1");
assertTrue (pElem->hasAttributes());
assertTrue (pElem->hasAttribute("a1"));
assertTrue (pElem->getAttribute("a1") == "v1");
Attr* pAttr1 = pElem->getAttributeNode("a1");
assertTrue (pAttr1 != 0);
assertTrue (pAttr1->name() == "a1");
@ -63,19 +63,19 @@ void ElementTest::testAttributes()
assertTrue (pAttr1->ownerElement() == pElem);
assertTrue (pAttr1->ownerDocument() == pDoc);
assertTrue (pAttr1->innerText() == "v1");
assertTrue (pAttr1->previousSibling() == 0);
assertTrue (pAttr1->nextSibling() == 0);
pAttr1->setValue("V1");
assertTrue (pElem->getAttribute("a1") == "V1");
pElem->setAttribute("a2", "v2");
assertTrue (pElem->hasAttribute("a1"));
assertTrue (pElem->getAttribute("a1") == "V1");
assertTrue (pElem->hasAttribute("a2"));
assertTrue (pElem->getAttribute("a2") == "v2");
Attr* pAttr2 = pElem->getAttributeNode("a2");
assertTrue (pAttr2 != 0);
assertTrue (pAttr2->name() == "a2");
@ -94,7 +94,7 @@ void ElementTest::testAttributes()
pAttr3->setValue("v3");
pElem->setAttributeNode(pAttr3);
pAttr3->release();
assertTrue (pElem->hasAttribute("a1"));
assertTrue (pElem->getAttribute("a1") == "V1");
assertTrue (pElem->hasAttribute("a2"));
@ -108,7 +108,7 @@ void ElementTest::testAttributes()
assertTrue (pAttr2->nextSibling() == pAttr3);
assertTrue (pAttr3->previousSibling() == pAttr2);
assertTrue (pAttr3->nextSibling() == 0);
pAttr2 = pDoc->createAttribute("a2");
pAttr2->setValue("V2");
pElem->setAttributeNode(pAttr2);
@ -120,12 +120,12 @@ void ElementTest::testAttributes()
assertTrue (pElem->getAttribute("a2") == "V2");
assertTrue (pElem->hasAttribute("a3"));
assertTrue (pElem->getAttribute("a3") == "v3");
pAttr1 = pDoc->createAttribute("a1");
pAttr1->setValue("v1");
pElem->setAttributeNode(pAttr1);
pAttr1->release();
assertTrue (pElem->hasAttribute("a1"));
assertTrue (pElem->getAttribute("a1") == "v1");
assertTrue (pElem->hasAttribute("a2"));
@ -144,16 +144,16 @@ void ElementTest::testAttributes()
assertTrue (pElem->getAttribute("a2") == "V2");
assertTrue (pElem->hasAttribute("a3"));
assertTrue (pElem->getAttribute("a3") == "V3");
pElem->removeAttributeNode(pAttr3);
assertTrue (!pElem->hasAttribute("a3"));
pElem->removeAttribute("a1");
assertTrue (!pElem->hasAttribute("a1"));
pElem->removeAttribute("a2");
assertTrue (!pElem->hasAttribute("a2"));
assertTrue (!pElem->hasAttributes());
}
@ -162,20 +162,20 @@ void ElementTest::testAttributesNS()
{
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pElem = pDoc->createElementNS("urn:ns1", "p:elem");
assertTrue (pElem->namespaceURI() == "urn:ns1");
assertTrue (pElem->prefix() == "p");
assertTrue (pElem->tagName() == "p:elem");
assertTrue (pElem->localName() == "elem");
assertTrue (!pElem->hasAttributes());
pElem->setAttributeNS("urn:ns1", "a1", "v1");
assertTrue (pElem->hasAttributes());
assertTrue (pElem->hasAttributeNS("urn:ns1", "a1"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a1") == "v1");
Attr* pAttr1 = pElem->getAttributeNodeNS("urn:ns1", "a1");
assertTrue (pAttr1 != 0);
assertTrue (pAttr1->name() == "a1");
@ -186,16 +186,16 @@ void ElementTest::testAttributesNS()
assertTrue (pAttr1->value() == "v1");
assertTrue (pAttr1->nodeValue() == "v1");
assertTrue (pAttr1->ownerElement() == pElem);
pAttr1->setValue("V1");
assertTrue (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
pElem->setAttributeNS("urn:ns1", "a2", "v2");
assertTrue (pElem->hasAttributeNS("urn:ns1", "a1"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
assertTrue (pElem->hasAttributeNS("urn:ns1", "a2"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a2") == "v2");
Attr* pAttr2 = pElem->getAttributeNodeNS("urn:ns1", "a2");
assertTrue (pAttr2 != 0);
assertTrue (pAttr2->name() == "a2");
@ -212,14 +212,14 @@ void ElementTest::testAttributesNS()
pAttr3->setValue("v3");
pElem->setAttributeNodeNS(pAttr3);
pAttr3->release();
assertTrue (pElem->hasAttributeNS("urn:ns1", "a1"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a1") == "V1");
assertTrue (pElem->hasAttributeNS("urn:ns1", "a2"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a2") == "v2");
assertTrue (pElem->hasAttributeNS("urn:ns2", "a3"));
assertTrue (pElem->getAttributeNS("urn:ns2", "a3") == "v3");
pAttr2 = pDoc->createAttributeNS("urn:ns1", "a2");
pAttr2->setValue("V2");
pElem->setAttributeNodeNS(pAttr2);
@ -231,12 +231,12 @@ void ElementTest::testAttributesNS()
assertTrue (pElem->getAttributeNS("urn:ns1", "a2") == "V2");
assertTrue (pElem->hasAttributeNS("urn:ns2", "a3"));
assertTrue (pElem->getAttributeNS("urn:ns2", "a3") == "v3");
pAttr1 = pDoc->createAttributeNS("urn:ns1", "a1");
pAttr1->setValue("v1");
pElem->setAttributeNodeNS(pAttr1);
pAttr1->release();
assertTrue (pElem->hasAttributeNS("urn:ns1", "a1"));
assertTrue (pElem->getAttributeNS("urn:ns1", "a1") == "v1");
assertTrue (pElem->hasAttributeNS("urn:ns1", "a2"));
@ -258,13 +258,13 @@ void ElementTest::testAttributesNS()
pElem->removeAttributeNode(pAttr3);
assertTrue (!pElem->hasAttributeNS("urn:ns2", "a3"));
pElem->removeAttributeNS("urn:ns1", "a1");
assertTrue (!pElem->hasAttributeNS("urn:ns1", "a1"));
pElem->removeAttributeNS("urn:ns1", "a2");
assertTrue (!pElem->hasAttributeNS("urn:ns1", "a2"));
assertTrue (!pElem->hasAttributes());
}
@ -276,7 +276,7 @@ void ElementTest::testAttrMap()
AutoPtr<NamedNodeMap> pNNM = pElem->attributes();
assertTrue (pNNM->length() == 0);
pElem->setAttribute("a1", "v1");
assertTrue (pNNM->length() == 1);
assertTrue (pNNM->item(0)->nodeName() == "a1");
@ -288,11 +288,11 @@ void ElementTest::testAttrMap()
assertTrue (pNNM->getNamedItem("a1")->nodeName() == "a1");
assertTrue (pNNM->item(1)->nodeName() == "a2");
assertTrue (pNNM->getNamedItem("a2")->nodeName() == "a2");
Attr* pAttr = pDoc->createAttribute("a3");
pNNM->setNamedItem(pAttr);
pAttr->release();
assertTrue (pNNM->length() == 3);
assertTrue (pNNM->item(0)->nodeName() == "a1");
assertTrue (pNNM->getNamedItem("a1")->nodeName() == "a1");
@ -304,11 +304,11 @@ void ElementTest::testAttrMap()
pNNM->removeNamedItem("a2");
assertTrue (pNNM->length() == 2);
assertTrue (!pElem->hasAttribute("a2"));
pNNM->removeNamedItem("a3");
assertTrue (pNNM->length() == 1);
assertTrue (!pElem->hasAttribute("a3"));
pElem->removeAttribute("a1");
assertTrue (pNNM->length() == 0);
}
@ -321,7 +321,7 @@ void ElementTest::testAttrMapNS()
AutoPtr<NamedNodeMap> pNNM = pElem->attributes();
assertTrue (pNNM->length() == 0);
pElem->setAttributeNS("urn:ns1", "a1", "v1");
assertTrue (pNNM->length() == 1);
assertTrue (pNNM->item(0)->nodeName() == "a1");
@ -333,11 +333,11 @@ void ElementTest::testAttrMapNS()
assertTrue (pNNM->getNamedItem("a1")->nodeName() == "a1");
assertTrue (pNNM->item(1)->nodeName() == "a2");
assertTrue (pNNM->getNamedItem("a2")->nodeName() == "a2");
Attr* pAttr = pDoc->createAttributeNS("urn:ns2", "a3");
pNNM->setNamedItem(pAttr);
pAttr->release();
assertTrue (pNNM->length() == 3);
assertTrue (pNNM->item(0)->nodeName() == "a1");
assertTrue (pNNM->getNamedItemNS("urn:ns1", "a1")->nodeName() == "a1");
@ -349,11 +349,11 @@ void ElementTest::testAttrMapNS()
pNNM->removeNamedItemNS("urn:ns1", "a2");
assertTrue (pNNM->length() == 2);
assertTrue (!pElem->hasAttributeNS("urn:ns1", "a2"));
pNNM->removeNamedItemNS("urn:ns2", "a3");
assertTrue (pNNM->length() == 1);
assertTrue (!pElem->hasAttributeNS("urn:ns2", "a3"));
pElem->removeAttributeNS("urn:ns1", "a1");
assertTrue (pNNM->length() == 0);
}
@ -365,13 +365,13 @@ void ElementTest::testElementsByTagName()
AutoPtr<Element> pRoot = pDoc->createElement("root");
AutoPtr<NodeList> pNL1 = pRoot->getElementsByTagName("*");
AutoPtr<NodeList> pNL2 = pRoot->getElementsByTagName("elem");
assertTrue (pNL1->length() == 0);
assertTrue (pNL2->length() == 0);
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
pRoot->appendChild(pElem1);
assertTrue (pNL1->length() == 1);
assertTrue (pNL2->length() == 1);
assertTrue (pNL1->item(0) == pElem1);
@ -396,7 +396,7 @@ void ElementTest::testElementsByTagName()
assertTrue (pNL1->item(2) == pElem3);
assertTrue (pNL2->item(0) == pElem1);
assertTrue (pNL2->item(1) == pElem3);
AutoPtr<Element> pElem11 = pDoc->createElement("elem");
pElem1->appendChild(pElem11);
@ -449,13 +449,13 @@ void ElementTest::testElementsByTagNameNS()
AutoPtr<NodeList> pNL1 = pRoot->getElementsByTagNameNS("*", "*");
AutoPtr<NodeList> pNL2 = pRoot->getElementsByTagNameNS("*", "elem");
AutoPtr<NodeList> pNL3 = pRoot->getElementsByTagNameNS("urn:ns1", "elem");
assertTrue (pNL1->length() == 0);
assertTrue (pNL2->length() == 0);
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "elem");
pRoot->appendChild(pElem1);
assertTrue (pNL1->length() == 1);
assertTrue (pNL2->length() == 1);
assertTrue (pNL3->length() == 1);
@ -486,7 +486,7 @@ void ElementTest::testElementsByTagNameNS()
assertTrue (pNL2->item(0) == pElem1);
assertTrue (pNL2->item(1) == pElem3);
assertTrue (pNL3->item(0) == pElem1);
AutoPtr<Element> pElem11 = pDoc->createElementNS("urn:ns1", "elem");
pElem1->appendChild(pElem11);
@ -550,12 +550,12 @@ void ElementTest::testInnerText()
AutoPtr<Element> pElem1 = pDoc->createElement("elem1");
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
AutoPtr<Text> pText3 = pDoc->createTextNode("text3");
pElem1->appendChild(pText2);
pRoot->appendChild(pText1);
pRoot->appendChild(pElem1);
pRoot->appendChild(pText3);
XMLString innerText = pRoot->innerText();
assertTrue (innerText == "text1text2text3");
}
@ -569,17 +569,17 @@ void ElementTest::testChildElement()
AutoPtr<Element> pElem2 = pDoc->createElement("elem2");
AutoPtr<Element> pElem3 = pDoc->createElement("elem3");
AutoPtr<Element> pElem4 = pDoc->createElement("elem3");
pRoot->appendChild(pElem1);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem3);
pRoot->appendChild(pElem4);
assertTrue (pRoot->getChildElement("elem1") == pElem1);
assertTrue (pRoot->getChildElement("elem2") == pElem2);
assertTrue (pRoot->getChildElement("elem3") == pElem3);
assertTrue (pRoot->getChildElement("elem4") == 0);
assertTrue (pElem1->getChildElement("elem11") == 0);
}
@ -592,18 +592,18 @@ void ElementTest::testChildElementNS()
AutoPtr<Element> pElem2 = pDoc->createElementNS("urn:ns", "elem2");
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns", "elem3");
AutoPtr<Element> pElem4 = pDoc->createElementNS("urn:ns", "elem3");
pRoot->appendChild(pElem1);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem3);
pRoot->appendChild(pElem4);
assertTrue (pRoot->getChildElementNS("urn:ns", "elem1") == pElem1);
assertTrue (pRoot->getChildElementNS("urn:ns", "elem2") == pElem2);
assertTrue (pRoot->getChildElementNS("urn:ns", "elem3") == pElem3);
assertTrue (pRoot->getChildElementNS("urn:ns", "elem4") == 0);
assertTrue (pRoot->getChildElementNS("urn:NS", "elem1") == 0);
assertTrue (pElem1->getChildElementNS("urn:ns", "elem11") == 0);
}
@ -616,7 +616,7 @@ void ElementTest::testNodeByPath()
<elemA/>
<elemA/>
</elem1>
<elem2>
<elem2 index="0">
<elemB attr1="value1"/>
<elemB attr1="value2"/>
<elemB attr1="value3"/>
@ -626,14 +626,15 @@ void ElementTest::testNodeByPath()
</elemC>
<elemC attr1="value2"/>
</elem2>
<elem2>
<elem2 index="1">
<elemB attr1="value4"/>
<elemD attr1="value1"/>
</elem2>
</root>
*/
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pRoot = pDoc->createElement("root");
AutoPtr<Element> pElem1 = pDoc->createElement("elem1");
AutoPtr<Element> pElem11 = pDoc->createElement("elemA");
@ -646,22 +647,27 @@ void ElementTest::testNodeByPath()
AutoPtr<Element> pElem25 = pDoc->createElement("elemC");
AutoPtr<Element> pElem3 = pDoc->createElement("elem2");
AutoPtr<Element> pElem31 = pDoc->createElement("elemB");
AutoPtr<Element> pElem32 = pDoc->createElement("elemD");
pElem2->setAttribute("index", "0");
pElem3->setAttribute("index", "1");
pElem21->setAttribute("attr1", "value1");
pElem22->setAttribute("attr1", "value2");
pElem23->setAttribute("attr1", "value3");
pElem24->setAttribute("attr1", "value1");
pElem25->setAttribute("attr1", "value2");
pElem31->setAttribute("attr1", "value4");
pElem32->setAttribute("attr1", "value1");
AutoPtr<Element> pElem241 = pDoc->createElement("elemC1");
AutoPtr<Element> pElem242 = pDoc->createElement("elemC2");
pElem241->setAttribute("attr1", "value1");
pElem24->appendChild(pElem241);
pElem24->appendChild(pElem242);
pElem1->appendChild(pElem11);
pElem1->appendChild(pElem12);
pElem2->appendChild(pElem21);
@ -669,42 +675,43 @@ void ElementTest::testNodeByPath()
pElem2->appendChild(pElem23);
pElem2->appendChild(pElem24);
pElem2->appendChild(pElem25);
pElem3->appendChild(pElem31);
pElem3->appendChild(pElem32);
pRoot->appendChild(pElem1);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem3);
pDoc->appendChild(pRoot);
Node* pNode = pRoot->getNodeByPath("/");
assertTrue (pNode == pRoot);
pNode = pRoot->getNodeByPath("/elem1");
assertTrue (pNode == pElem1);
pNode = pDoc->getNodeByPath("/root/elem1");
assertTrue (pNode == pElem1);
pNode = pRoot->getNodeByPath("/elem2");
assertTrue (pNode == pElem2);
pNode = pRoot->getNodeByPath("/elem1/elemA");
assertTrue (pNode == pElem11);
pNode = pRoot->getNodeByPath("/elem1/elemA[0]");
assertTrue (pNode == pElem11);
pNode = pRoot->getNodeByPath("/elem1/elemA[1]");
assertTrue (pNode == pElem12);
pNode = pRoot->getNodeByPath("/elem1/elemA[2]");
assertTrue (pNode == 0);
pNode = pRoot->getNodeByPath("/elem2/elemB");
assertTrue (pNode == pElem21);
pNode = pRoot->getNodeByPath("/elem2/elemB[0]");
assertTrue (pNode == pElem21);
@ -716,7 +723,7 @@ void ElementTest::testNodeByPath()
pNode = pRoot->getNodeByPath("/elem2/elemB[3]");
assertTrue (pNode == 0);
pNode = pRoot->getNodeByPath("/elem2/elemB[@attr1]");
assertTrue (pNode && pNode->nodeValue() == "value1");
@ -734,7 +741,7 @@ void ElementTest::testNodeByPath()
pNode = pDoc->getNodeByPath("//elemB[@attr1='value1']");
assertTrue (pNode == pElem21);
pNode = pDoc->getNodeByPath("//elemB[@attr1='value2']");
assertTrue (pNode == pElem22);
@ -750,11 +757,32 @@ void ElementTest::testNodeByPath()
pNode = pDoc->getNodeByPath("//[@attr1='value1']");
assertTrue (pNode == pElem21);
pNode = pDoc->getNodeByPath("//[@attr1='value4']");
assertTrue (pNode == pElem31);
pNode = pDoc->getNodeByPath("//[@attr1='value2']");
assertTrue (pNode == pElem22);
pNode = pRoot->getNodeByPath("/elem2/*[@attr1='value2']");
assertTrue (pNode == pElem22);
pNode = pDoc->getNodeByPath("/root/elem2[0]/elemC");
assertTrue (pNode == pElem24);
pNode = pDoc->getNodeByPath("/root/elem2[1]/elemC");
assertTrue (pNode == 0);
pNode = pDoc->getNodeByPath("/root/elem2[0]/elemD");
assertTrue (pNode == 0);
pNode = pDoc->getNodeByPath("/root/elem2[1]/elemD");
assertTrue (pNode == pElem32);
pNode = pDoc->getNodeByPath("/root/elem2[@index=0]/elemD");
assertTrue (pNode == 0);
pNode = pDoc->getNodeByPath("/root/elem2[@index=1]/elemD");
assertTrue (pNode == pElem32);
}
@ -779,10 +807,10 @@ void ElementTest::testNodeByPathNS()
<ns1:elem2>
<ns2:elemB ns2:attr1="value4" xmlns:ns2="urn:ns2"/>
</ns1:elem2>
</ns1:root>
</ns1:root>
*/
AutoPtr<Document> pDoc = new Document;
AutoPtr<Element> pRoot = pDoc->createElementNS("urn:ns1", "ns1:root");
AutoPtr<Element> pElem1 = pDoc->createElementNS("urn:ns1", "ns1:elem1");
AutoPtr<Element> pElem11 = pDoc->createElementNS("urn:ns2", "ns2:elemA");
@ -795,21 +823,21 @@ void ElementTest::testNodeByPathNS()
AutoPtr<Element> pElem25 = pDoc->createElementNS("urn:ns2", "ns2:elemC");
AutoPtr<Element> pElem3 = pDoc->createElementNS("urn:ns1", "ns1:elem2");
AutoPtr<Element> pElem31 = pDoc->createElementNS("urn:ns2", "ns2:elemB");
pElem21->setAttributeNS("urn:ns2", "ns2:attr1", "value1");
pElem22->setAttributeNS("urn:ns2", "ns2:attr1", "value2");
pElem23->setAttributeNS("urn:ns2", "ns2:attr1", "value3");
pElem31->setAttributeNS("urn:ns2", "ns2:attr1", "value4");
pElem24->setAttributeNS("urn:ns2", "ns2:attr1", "value1");
pElem25->setAttributeNS("urn:ns2", "ns2:attr1", "value2");
AutoPtr<Element> pElem241 = pDoc->createElementNS("urn:ns2", "elemC1");
AutoPtr<Element> pElem242 = pDoc->createElementNS("urn:ns2", "elemC2");
pElem241->setAttributeNS("urn:ns2", "ns2:attr1", "value1");
pElem24->appendChild(pElem241);
pElem24->appendChild(pElem242);
pElem1->appendChild(pElem11);
pElem1->appendChild(pElem12);
pElem2->appendChild(pElem21);
@ -820,18 +848,18 @@ void ElementTest::testNodeByPathNS()
pElem3->appendChild(pElem31);
pRoot->appendChild(pElem1);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem2);
pRoot->appendChild(pElem3);
pDoc->appendChild(pRoot);
Element::NSMap nsMap;
nsMap.declarePrefix("ns1", "urn:ns1");
nsMap.declarePrefix("NS2", "urn:ns2");
Node* pNode = pRoot->getNodeByPathNS("/", nsMap);
assertTrue (pNode == pRoot);
pNode = pRoot->getNodeByPathNS("/ns1:elem1", nsMap);
assertTrue (pNode == pElem1);
@ -840,22 +868,22 @@ void ElementTest::testNodeByPathNS()
pNode = pRoot->getNodeByPathNS("/ns1:elem2", nsMap);
assertTrue (pNode == pElem2);
pNode = pRoot->getNodeByPathNS("/ns1:elem1/NS2:elemA", nsMap);
assertTrue (pNode == pElem11);
pNode = pRoot->getNodeByPathNS("/ns1:elem1/NS2:elemA[0]", nsMap);
assertTrue (pNode == pElem11);
pNode = pRoot->getNodeByPathNS("/ns1:elem1/NS2:elemA[1]", nsMap);
assertTrue (pNode == pElem12);
pNode = pRoot->getNodeByPathNS("/ns1:elem1/NS2:elemA[2]", nsMap);
assertTrue (pNode == 0);
pNode = pRoot->getNodeByPathNS("/ns1:elem2/NS2:elemB", nsMap);
assertTrue (pNode == pElem21);
pNode = pRoot->getNodeByPathNS("/ns1:elem2/NS2:elemB[0]", nsMap);
assertTrue (pNode == pElem21);
@ -867,7 +895,7 @@ void ElementTest::testNodeByPathNS()
pNode = pRoot->getNodeByPathNS("/ns1:elem2/NS2:elemB[3]", nsMap);
assertTrue (pNode == 0);
pNode = pRoot->getNodeByPathNS("/ns1:elem2/NS2:elemB[@NS2:attr1]", nsMap);
assertTrue (pNode && pNode->nodeValue() == "value1");
@ -888,7 +916,7 @@ void ElementTest::testNodeByPathNS()
pNode = pDoc->getNodeByPathNS("//NS2:elemB[@NS2:attr1='value1']", nsMap);
assertTrue (pNode == pElem21);
pNode = pDoc->getNodeByPathNS("//NS2:elemB[@NS2:attr1='value2']", nsMap);
assertTrue (pNode == pElem22);
@ -903,10 +931,10 @@ void ElementTest::testNodeByPathNS()
pNode = pDoc->getNodeByPathNS("//[@NS2:attr1='value1']", nsMap);
assertTrue (pNode == pElem21);
pNode = pDoc->getNodeByPathNS("//[@NS2:attr1='value2']", nsMap);
assertTrue (pNode == pElem22);
pNode = pRoot->getNodeByPathNS("/ns1:elem2/*[@NS2:attr1='value2']", nsMap);
assertTrue (pNode == pElem22);
@ -945,4 +973,4 @@ CppUnit::Test* ElementTest::suite()
CppUnit_addTest(pSuite, ElementTest, testNodeByPathNS);
return pSuite;
}
}