https://issues.shibboleth.net/jira/browse/SSPCPP-522
authorScott Cantor <cantor.2@osu.edu>
Fri, 2 Nov 2012 20:22:00 +0000 (20:22 +0000)
committerScott Cantor <cantor.2@osu.edu>
Fri, 2 Nov 2012 20:22:00 +0000 (20:22 +0000)
plugins/TransformAttributeResolver.cpp

index 6b4bf7b..e036748 100644 (file)
@@ -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());