mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-17 18:12:04 +01:00
Check attribute names in setAttribute
This commit is contained in:
parent
4d20439527
commit
56a3f9397f
3 changed files with 25 additions and 25 deletions
|
@ -15,7 +15,6 @@
|
|||
#include <DOM/Simple/NotationImpl.hpp>
|
||||
#include <DOM/Simple/ElementByTagImpl.hpp>
|
||||
#include <DOM/Simple/NodeImpl.hpp>
|
||||
#include <XML/XMLCharacterClasses.hpp>
|
||||
|
||||
#include <set>
|
||||
#include <list>
|
||||
|
@ -527,28 +526,6 @@ class DocumentImpl : public DOM::Document_impl<stringT, string_adaptorT>,
|
|||
throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR);
|
||||
} // checkChildType
|
||||
|
||||
void checkName(const stringT& str) const
|
||||
{
|
||||
if(string_adaptorT::length(str) == 0)
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
typedef typename string_adaptorT::const_iterator const_iterator;
|
||||
const_iterator i = string_adaptorT::begin(str);
|
||||
const_iterator ie = string_adaptorT::end(str);
|
||||
for( ; i != ie; ++i)
|
||||
if(!XML::is_name_char(*i))
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
} // checkName
|
||||
|
||||
void checkChars(const stringT& str) const
|
||||
{
|
||||
typedef typename string_adaptorT::const_iterator const_iterator;
|
||||
const_iterator i = string_adaptorT::begin(str);
|
||||
const_iterator ie = string_adaptorT::end(str);
|
||||
for( ; i != ie; ++i)
|
||||
if(!XML::is_char(*i))
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
} // checkChars
|
||||
|
||||
private:
|
||||
DOMElement_implT* documentElement_;
|
||||
DOMDocumentType_implT* documentType_;
|
||||
|
|
|
@ -51,6 +51,7 @@ class ElementImpl : public DOM::Element_impl<stringT, string_adaptorT>,
|
|||
|
||||
virtual void setAttribute(const stringT& name, const stringT& value)
|
||||
{
|
||||
checkName(name);
|
||||
attributes_.setAttribute(name, value);
|
||||
} // setAttribute
|
||||
|
||||
|
@ -88,6 +89,7 @@ class ElementImpl : public DOM::Element_impl<stringT, string_adaptorT>,
|
|||
|
||||
virtual void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value)
|
||||
{
|
||||
checkName(qualifiedName);
|
||||
attributes_.setAttributeNS(namespaceURI, qualifiedName, value);
|
||||
} // setAttributeNS
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
|
||||
////////////////////////////
|
||||
// C++ DOM definition
|
||||
//
|
||||
// $Id$
|
||||
////////////////////////////
|
||||
|
||||
#include <DOM/Node.hpp>
|
||||
#include <DOM/DOMException.hpp>
|
||||
#include <XML/XMLCharacterClasses.hpp>
|
||||
#include <deque>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -205,6 +204,28 @@ class NodeImpl : virtual public DOM::Node_impl<stringT, string_adaptorT>
|
|||
} // throwIfReadOnly
|
||||
|
||||
protected:
|
||||
void checkName(const stringT& str) const
|
||||
{
|
||||
if(string_adaptorT::length(str) == 0)
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
typedef typename string_adaptorT::const_iterator const_iterator;
|
||||
const_iterator i = string_adaptorT::begin(str);
|
||||
const_iterator ie = string_adaptorT::end(str);
|
||||
for( ; i != ie; ++i)
|
||||
if(!XML::is_name_char(*i))
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
} // checkName
|
||||
|
||||
void checkChars(const stringT& str) const
|
||||
{
|
||||
typedef typename string_adaptorT::const_iterator const_iterator;
|
||||
const_iterator i = string_adaptorT::begin(str);
|
||||
const_iterator ie = string_adaptorT::end(str);
|
||||
for( ; i != ie; ++i)
|
||||
if(!XML::is_char(*i))
|
||||
throw DOM::DOMException(DOM::DOMException::INVALID_CHARACTER_ERR);
|
||||
} // checkChars
|
||||
|
||||
NodeImplT* parentNode_;
|
||||
DocumentImplT* ownerDoc_;
|
||||
NodeImplT* prevSibling_;
|
||||
|
|
Loading…
Reference in a new issue