[cpp-sp] branch master updated: CPPXT-133 - Eliminate uses of getTextContent in DOM helpers
Scott Cantor
cantor.2 at osu.edu
Wed Jul 11 14:20:04 EDT 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=711719bfab4534e32dd4ceda8a266e98b0891593
The following commit(s) were added to refs/heads/master by this push:
new 711719b CPPXT-133 - Eliminate uses of getTextContent in DOM helpers
711719b is described below
commit 711719bfab4534e32dd4ceda8a266e98b0891593
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 11 14:19:45 2018 -0400
CPPXT-133 - Eliminate uses of getTextContent in DOM helpers
https://issues.shibboleth.net/jira/browse/CPPXT-133
---
Projects/vc15/Shibboleth.sln | 1 +
isapi_shib/isapi_shib.cpp | 2 +-
memcache-store/memcache-store.cpp | 2 +-
odbc-store/odbc-store.cpp | 4 ++--
plugins/TemplateAttributeResolver.cpp | 4 ++--
plugins/TimeAccessControl.cpp | 4 ++--
plugins/TransformAttributeResolver.cpp | 4 ++--
shibsp/attribute/DOMAttributeDecoder.cpp | 9 ++++++---
shibsp/handler/impl/TransformSessionInitiator.cpp | 4 ++--
shibsp/impl/XMLAccessControl.cpp | 2 +-
shibsp/impl/XMLApplication.cpp | 6 +++---
11 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/Projects/vc15/Shibboleth.sln b/Projects/vc15/Shibboleth.sln
index a1a4e96..ca6502a 100644
--- a/Projects/vc15/Shibboleth.sln
+++ b/Projects/vc15/Shibboleth.sln
@@ -342,6 +342,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
+ {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050} = {0F172F71-BDD7-44D1-9147-061DC20683BD}
{8E1AF2CF-24E1-4983-8681-394D89DF9AD2} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
{87C25D4E-8D19-4513-B0BA-BC668BC2DEE3} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
{666A63A7-983F-4C19-8411-207F24305197} = {96AE4FC9-45EF-4C18-9F3B-EDA439E26E4C}
diff --git a/isapi_shib/isapi_shib.cpp b/isapi_shib/isapi_shib.cpp
index 21bcadd..5a74328 100644
--- a/isapi_shib/isapi_shib.cpp
+++ b/isapi_shib/isapi_shib.cpp
@@ -88,7 +88,7 @@ namespace {
e = XMLHelper::getFirstChildElement(e, Alias);
while (e) {
if (e->hasChildNodes()) {
- auto_ptr_char alias(e->getTextContent());
+ auto_ptr_char alias(XMLHelper::getTextContent(e));
m_aliases.insert(alias.get());
}
e = XMLHelper::getNextSiblingElement(e, Alias);
diff --git a/memcache-store/memcache-store.cpp b/memcache-store/memcache-store.cpp
index 08db24d..24e6c86 100644
--- a/memcache-store/memcache-store.cpp
+++ b/memcache-store/memcache-store.cpp
@@ -192,7 +192,7 @@ MemcacheBase::MemcacheBase(const DOMElement* e)
memcached_free(memc);
throw XMLToolingException("Memcache StorageService requires Hosts element in configuration.");
}
- auto_ptr_char h(e->getTextContent());
+ auto_ptr_char h(XMLHelper::getTextContent(e));
m_log.debug("INIT: GOT Hosts: %s", h.get());
memcached_server_st* servers;
servers = memcached_servers_parse(const_cast<char*>(h.get()));
diff --git a/odbc-store/odbc-store.cpp b/odbc-store/odbc-store.cpp
index 7ace54c..2316e95 100644
--- a/odbc-store/odbc-store.cpp
+++ b/odbc-store/odbc-store.cpp
@@ -307,7 +307,7 @@ ODBCStorageService::ODBCStorageService(const DOMElement* e) : m_log(Category::ge
// Grab connection string from the configuration.
e = e ? XMLHelper::getFirstChildElement(e, ConnectionString) : nullptr;
- auto_ptr_char arg(e ? e->getTextContent() : nullptr);
+ auto_ptr_char arg(XMLHelper::getTextContent(e));
if (!arg.get() || !*arg.get()) {
SQLFreeHandle(SQL_HANDLE_ENV, m_henv);
throw XMLToolingException("ODBC StorageService requires ConnectionString element in configuration.");
@@ -335,7 +335,7 @@ ODBCStorageService::ODBCStorageService(const DOMElement* e) : m_log(Category::ge
while (e) {
if (e->hasChildNodes()) {
try {
- int code = XMLString::parseInt(e->getTextContent());
+ int code = XMLString::parseInt(XMLHelper::getTextContent(e));
m_retries.push_back(code);
m_log.info("will retry operations when native ODBC error (%d) is returned", code);
}
diff --git a/plugins/TemplateAttributeResolver.cpp b/plugins/TemplateAttributeResolver.cpp
index 4472378..ba8ceac 100644
--- a/plugins/TemplateAttributeResolver.cpp
+++ b/plugins/TemplateAttributeResolver.cpp
@@ -142,13 +142,13 @@ TemplateAttributeResolver::TemplateAttributeResolver(const DOMElement* e)
throw ConfigurationException("Template AttributeResolver requires sources attribute.");
e = e ? XMLHelper::getFirstChildElement(e, Template) : nullptr;
- auto_ptr_char t(e ? e->getTextContent() : nullptr);
+ auto_ptr_char t(XMLHelper::getTextContent(e));
if (t.get()) {
m_template = t.get();
trim(m_template);
}
if (m_template.empty())
- throw ConfigurationException("Template AttributeResolver requires <Template> child element.");
+ throw ConfigurationException("Template AttributeResolver requires non-empty <Template> child element.");
}
diff --git a/plugins/TimeAccessControl.cpp b/plugins/TimeAccessControl.cpp
index d2843bf..7c41109 100644
--- a/plugins/TimeAccessControl.cpp
+++ b/plugins/TimeAccessControl.cpp
@@ -106,13 +106,13 @@ Rule::Rule(const DOMElement* e)
{
if (XMLString::equals(e->getLocalName(), TimeSinceAuthn)) {
m_type = TM_AUTHN;
- XMLDateTime dur(e->getTextContent());
+ XMLDateTime dur(XMLHelper::getTextContent(e));
dur.parseDuration();
m_value = dur.getEpoch(true);
return;
}
- auto_ptr_char temp(e->getTextContent());
+ auto_ptr_char temp(XMLHelper::getTextContent(e));
string s(temp.get() ? temp.get() : "");
trim(s);
vector<string> tokens;
diff --git a/plugins/TransformAttributeResolver.cpp b/plugins/TransformAttributeResolver.cpp
index 0685903..50a5aa7 100644
--- a/plugins/TransformAttributeResolver.cpp
+++ b/plugins/TransformAttributeResolver.cpp
@@ -147,7 +147,7 @@ TransformAttributeResolver::TransformAttributeResolver(const DOMElement* e)
e = XMLHelper::getFirstChildElement(e, Regex);
while (e) {
if (e->hasChildNodes() && e->hasAttributeNS(nullptr, match)) {
- const XMLCh* repl(e->getTextContent());
+ const XMLCh* repl(XMLHelper::getTextContent(e));
string destId(XMLHelper::getAttrString(e, nullptr, dest));
bool caseflag(XMLHelper::getAttrBool(e, true, caseSensitive));
if (repl && *repl) {
@@ -167,7 +167,7 @@ TransformAttributeResolver::TransformAttributeResolver(const DOMElement* e)
}
if (m_regex.empty())
- throw ConfigurationException("Transform AttributeResolver requires at least one Regex element.");
+ throw ConfigurationException("Transform AttributeResolver requires at least one non-empty Regex element.");
}
diff --git a/shibsp/attribute/DOMAttributeDecoder.cpp b/shibsp/attribute/DOMAttributeDecoder.cpp
index ce6056b..045af03 100644
--- a/shibsp/attribute/DOMAttributeDecoder.cpp
+++ b/shibsp/attribute/DOMAttributeDecoder.cpp
@@ -191,9 +191,12 @@ DDF DOMAttributeDecoder::convert(DOMElement* e, bool nameit) const
}
DOMElement* child = XMLHelper::getFirstChildElement(e);
- if (!child && e->hasChildNodes() && e->getFirstChild()->getNodeType() == DOMNode::TEXT_NODE) {
- // Attach a _text member if a text node is present.
- obj.addmember("_string").string(toUTF8(e->getFirstChild()->getTextContent(), true), false);
+ if (!child && e->hasChildNodes()) {
+ // Attach a _text member if text data is present.
+ XMLCh* value = XMLHelper::getWholeTextContent(e);
+ ArrayJanitor<XMLCh> jan(value);
+ if (value && *value)
+ obj.addmember("_string").string(toUTF8(value, true), false);
}
else {
while (child) {
diff --git a/shibsp/handler/impl/TransformSessionInitiator.cpp b/shibsp/handler/impl/TransformSessionInitiator.cpp
index 2e6680c..b564472 100644
--- a/shibsp/handler/impl/TransformSessionInitiator.cpp
+++ b/shibsp/handler/impl/TransformSessionInitiator.cpp
@@ -96,13 +96,13 @@ namespace shibsp {
if (e->hasChildNodes()) {
bool flag = XMLHelper::getAttrBool(e, false, force);
if (XMLString::equals(e->getLocalName(), Subst)) {
- auto_ptr_char temp(e->getTextContent());
+ auto_ptr_char temp(XMLHelper::getTextContent(e));
if (temp.get() && *temp.get())
m_subst.push_back(pair<bool,string>(flag, temp.get()));
}
else if (XMLString::equals(e->getLocalName(), Regex) && e->hasAttributeNS(nullptr, match)) {
auto_ptr_char m(e->getAttributeNS(nullptr, match));
- auto_ptr_char repl(e->getTextContent());
+ auto_ptr_char repl(XMLHelper::getTextContent(e));
if (m.get() && *m.get() && repl.get() && *repl.get())
m_regex.push_back(boost::tuple<bool,string,string>(flag, m.get(), repl.get()));
}
diff --git a/shibsp/impl/XMLAccessControl.cpp b/shibsp/impl/XMLAccessControl.cpp
index d71c4c7..35737c2 100644
--- a/shibsp/impl/XMLAccessControl.cpp
+++ b/shibsp/impl/XMLAccessControl.cpp
@@ -156,7 +156,7 @@ Rule::Rule(const DOMElement* e) : m_alias(XMLHelper::getAttrString(e, nullptr, r
if (!e->hasChildNodes())
return; // empty rule
- auto_arrayptr<char> vals(toUTF8(e->getTextContent()));
+ auto_arrayptr<char> vals(toUTF8(XMLHelper::getTextContent(e)));
if (!vals.get() || !*vals.get())
throw ConfigurationException("Unable to convert Rule content into UTF-8.");
diff --git a/shibsp/impl/XMLApplication.cpp b/shibsp/impl/XMLApplication.cpp
index 95b677e..a40f261 100644
--- a/shibsp/impl/XMLApplication.cpp
+++ b/shibsp/impl/XMLApplication.cpp
@@ -683,7 +683,7 @@ void XMLApplication::doSSO(const ProtocolProvider& pp, set<string>& protocols, D
int index = 0; // track ACS indexes globally across all protocols
// Tokenize the protocol list inside the element.
- XMLStringTokenizer prottokens(e->getTextContent());
+ XMLStringTokenizer prottokens(XMLHelper::getTextContent(e));
while (prottokens.hasMoreTokens()) {
auto_ptr_char prot(prottokens.nextToken());
@@ -818,7 +818,7 @@ void XMLApplication::doLogout(const ProtocolProvider& pp, set<string>& protocols
const SPConfig& conf = SPConfig::getConfig();
// Tokenize the protocol list inside the element.
- XMLStringTokenizer prottokens(e->getTextContent());
+ XMLStringTokenizer prottokens(XMLHelper::getTextContent(e));
while (prottokens.hasMoreTokens()) {
auto_ptr_char prot(prottokens.nextToken());
@@ -924,7 +924,7 @@ void XMLApplication::doNameIDMgmt(const ProtocolProvider& pp, set<string>& proto
const SPConfig& conf = SPConfig::getConfig();
// Tokenize the protocol list inside the element.
- XMLStringTokenizer prottokens(e->getTextContent());
+ XMLStringTokenizer prottokens(XMLHelper::getTextContent(e));
while (prottokens.hasMoreTokens()) {
auto_ptr_char prot(prottokens.nextToken());
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list