SSPCPP-616 - clean up concatenated string literals
[shibboleth/cpp-sp.git] / plugins / TransformAttributeResolver.cpp
index 6b4bf7b..21a0246 100644 (file)
@@ -152,7 +152,7 @@ namespace shibsp {
 vector<opensaml::Assertion*> TransformContext::m_assertions;
 
 TransformAttributeResolver::TransformAttributeResolver(const DOMElement* e)
-    : m_log(Category::getInstance(SHIBSP_LOGCAT".AttributeResolver.Transform")),
+    : m_log(Category::getInstance(SHIBSP_LOGCAT ".AttributeResolver.Transform")),
         m_source(XMLHelper::getAttrString(e, nullptr, source))
 {
     if (m_source.empty())
@@ -227,7 +227,10 @@ void TransformAttributeResolver::resolveAttributes(ResolutionContext& ctx) const
                 try {
                     auto_arrayptr<XMLCh> srcval(fromUTF8((*a)->getSerializedValues()[i].c_str()));
                     XMLCh* destval = r->get<1>()->replace(srcval.get(), r->get<2>());
-                    if (destval) {
+                    if (!destval)
+                        continue;
+                    // For some reason, it returns the source string if the match doesn't succeed.
+                    if (!XMLString::equals(destval, srcval.get())) {
                         auto_arrayptr<char> narrow(toUTF8(destval));
                         XMLString::release(&destval);
                         if (dest) {
@@ -241,6 +244,9 @@ void TransformAttributeResolver::resolveAttributes(ResolutionContext& ctx) const
                             trim(destwrapper->getValues().back());
                         }
                     }
+                    else {
+                        XMLString::release(&destval);
+                    }
                 }
                 catch (XMLException& ex) {
                     auto_ptr_char msg(ex.getMessage());