[cpp-opensaml] branch master updated: CPPXT-133 - Eliminate uses of getTextContent in DOM helpers

Scott Cantor cantor.2 at osu.edu
Wed Jul 11 14:19:25 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-opensaml.git;a=commit;h=1228b11112d0bfc20ba0a12ab28678e66d08754a

The following commit(s) were added to refs/heads/master by this push:
       new  1228b11   CPPXT-133 - Eliminate uses of getTextContent in DOM helpers
1228b11 is described below

commit 1228b11112d0bfc20ba0a12ab28678e66d08754a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 11 14:19:02 2018 -0400

    CPPXT-133 - Eliminate uses of getTextContent in DOM helpers
    
    https://issues.shibboleth.net/jira/browse/CPPXT-133
---
 saml/saml1/core/impl/ProtocolsImpl.cpp                          | 8 ++++++--
 saml/saml2/metadata/impl/BlacklistMetadataFilter.cpp            | 2 +-
 saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp      | 4 ++--
 saml/saml2/metadata/impl/EntityAttributesMetadataFilter.cpp     | 2 +-
 saml/saml2/metadata/impl/RegistrationAuthorityEntityMatcher.cpp | 2 +-
 saml/saml2/metadata/impl/WhitelistMetadataFilter.cpp            | 2 +-
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/saml/saml1/core/impl/ProtocolsImpl.cpp b/saml/saml1/core/impl/ProtocolsImpl.cpp
index a39b81e..45f7961 100644
--- a/saml/saml1/core/impl/ProtocolsImpl.cpp
+++ b/saml/saml1/core/impl/ProtocolsImpl.cpp
@@ -86,8 +86,12 @@ namespace opensaml {
             }
 
             xmltooling::QName* getQName() const {
-                if (!m_qname && getDOM() && getDOM()->getTextContent()) {
-                    m_qname = XMLHelper::getNodeValueAsQName(getDOM());
+                if (!m_qname && getDOM() && getDOM()->hasChildNodes()) {
+                    try {
+                        m_qname = XMLHelper::getNodeValueAsQName(getDOM());
+                    } catch (std::exception&) {
+                        // unbound prefix will throw here
+                    }
                 }
                 return m_qname;
             }
diff --git a/saml/saml2/metadata/impl/BlacklistMetadataFilter.cpp b/saml/saml2/metadata/impl/BlacklistMetadataFilter.cpp
index ecd2b9e..fcad287 100644
--- a/saml/saml2/metadata/impl/BlacklistMetadataFilter.cpp
+++ b/saml/saml2/metadata/impl/BlacklistMetadataFilter.cpp
@@ -78,7 +78,7 @@ BlacklistMetadataFilter::BlacklistMetadataFilter(const DOMElement* e, bool depre
     e = XMLHelper::getFirstChildElement(e, Exclude);
     while (e) {
         if (e->hasChildNodes()) {
-            const XMLCh* excl = e->getTextContent();
+            const XMLCh* excl = XMLHelper::getTextContent(e);
             if (excl && *excl)
                 m_entities.insert(excl);
         }
diff --git a/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp b/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp
index 5ec9979..bf24037 100644
--- a/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp
+++ b/saml/saml2/metadata/impl/EntityAttributesEntityMatcher.cpp
@@ -185,7 +185,7 @@ bool EntityAttributesEntityMatcher::_matches(const EntityAttributes* ea, const A
                 // Check each tag value's simple content for a match.
                 for (vector<XMLObject*>::size_type tagindex = 0; tagindex < tagvals.size(); ++tagindex) {
                     const XMLObject* tagval = tagvals[tagindex];
-                    const XMLCh* tagvalstr = (tagval->getDOM()) ? tagval->getDOM()->getTextContent() : tagval->getTextContent();
+                    const XMLCh* tagvalstr = tagval->getTextContent();
                     re.reset();
 
                     // Check for a regex flag.
@@ -205,7 +205,7 @@ bool EntityAttributesEntityMatcher::_matches(const EntityAttributes* ea, const A
                     const vector<XMLObject*>& cvals = const_cast<const Attribute&>(*a).getAttributeValues();
                     for (indirect_iterator<vector<XMLObject*>::const_iterator> cval = make_indirect_iterator(cvals.begin());
                             cval != make_indirect_iterator(cvals.end()); ++cval) {
-                        const XMLCh* cvalstr = cval->getDOM() ? cval->getDOM()->getTextContent() : cval->getTextContent();
+                        const XMLCh* cvalstr = cval->getTextContent();
                         if (tagvalstr && cvalstr) {
                             if (re) {
                                 try {
diff --git a/saml/saml2/metadata/impl/EntityAttributesMetadataFilter.cpp b/saml/saml2/metadata/impl/EntityAttributesMetadataFilter.cpp
index f9a1d13..3fb7451 100644
--- a/saml/saml2/metadata/impl/EntityAttributesMetadataFilter.cpp
+++ b/saml/saml2/metadata/impl/EntityAttributesMetadataFilter.cpp
@@ -87,7 +87,7 @@ EntityAttributesMetadataFilter::EntityAttributesMetadataFilter(const DOMElement*
             m_attributes.push_back(boost::dynamic_pointer_cast<Attribute>(obj));
         }
         else if (XMLString::equals(child->getLocalName(), Entity)) {
-            const XMLCh* eid = child->getTextContent();
+            const XMLCh* eid = XMLHelper::getTextContent(child);
             if (eid && *eid) {
                 for (vector< boost::shared_ptr<Attribute> >::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a)
                     m_applyMap.insert(applymap_t::value_type(eid, a->get()));
diff --git a/saml/saml2/metadata/impl/RegistrationAuthorityEntityMatcher.cpp b/saml/saml2/metadata/impl/RegistrationAuthorityEntityMatcher.cpp
index 4a49c19..0f851df 100644
--- a/saml/saml2/metadata/impl/RegistrationAuthorityEntityMatcher.cpp
+++ b/saml/saml2/metadata/impl/RegistrationAuthorityEntityMatcher.cpp
@@ -77,7 +77,7 @@ RegistrationAuthorityEntityMatcher::RegistrationAuthorityEntityMatcher(const DOM
 
     const DOMElement* child = XMLHelper::getFirstChildElement(e, RegistrationInfo::REGAUTHORITY_ATTRIB_NAME);
     while (child) {
-        const XMLCh* text = child->getTextContent();
+        const XMLCh* text = XMLHelper::getTextContent(child);
         if (text && *text) {
             m_authorities.insert(text);
         }
diff --git a/saml/saml2/metadata/impl/WhitelistMetadataFilter.cpp b/saml/saml2/metadata/impl/WhitelistMetadataFilter.cpp
index bdf6257..b3f9cf3 100644
--- a/saml/saml2/metadata/impl/WhitelistMetadataFilter.cpp
+++ b/saml/saml2/metadata/impl/WhitelistMetadataFilter.cpp
@@ -79,7 +79,7 @@ WhitelistMetadataFilter::WhitelistMetadataFilter(const DOMElement* e, bool depre
     e = XMLHelper::getFirstChildElement(e, Include);
     while (e) {
         if (e->hasChildNodes()) {
-            const XMLCh* incl = e->getTextContent();
+            const XMLCh* incl = XMLHelper::getTextContent(e);
             if (incl && *incl)
                 m_entities.insert(incl);
         }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list