X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=shibsp%2Fattribute%2Ffiltering%2Fimpl%2FAttributeValueRegexFunctor.cpp;fp=shibsp%2Fattribute%2Ffiltering%2Fimpl%2FAttributeValueRegexFunctor.cpp;h=b1315cd91b4bbd40e0742661b77fcbf71ed0b5f3;hb=997a4736b6fe81066e13822d3163de3a20cd6353;hp=39e77c6515de2a72a5690173c732011ea29cd410;hpb=d98a71ccae3e120443eae38ce73ef68404d0c9c2;p=shibboleth%2Fsp.git diff --git a/shibsp/attribute/filtering/impl/AttributeValueRegexFunctor.cpp b/shibsp/attribute/filtering/impl/AttributeValueRegexFunctor.cpp index 39e77c6..b1315cd 100644 --- a/shibsp/attribute/filtering/impl/AttributeValueRegexFunctor.cpp +++ b/shibsp/attribute/filtering/impl/AttributeValueRegexFunctor.cpp @@ -33,12 +33,12 @@ #include "attribute/filtering/MatchFunctor.h" #include - #include using namespace shibsp; +using namespace xmltooling; +using namespace boost; using namespace std; -using xmltooling::XMLHelper; namespace shibsp { @@ -52,19 +52,19 @@ namespace shibsp { class SHIBSP_DLLLOCAL AttributeValueRegexFunctor : public MatchFunctor { string m_attributeID; - RegularExpression* m_regex; + scoped_ptr m_regex; bool hasValue(const FilteringContext& filterContext) const; bool matches(const Attribute& attribute, size_t index) const; public: AttributeValueRegexFunctor(const DOMElement* e) - : m_attributeID(XMLHelper::getAttrString(e, nullptr, attributeID)), m_regex(nullptr) { - const XMLCh* r = e ? e->getAttributeNS(nullptr,regex) : nullptr; + : m_attributeID(XMLHelper::getAttrString(e, nullptr, attributeID)) { + const XMLCh* r = e ? e->getAttributeNS(nullptr, regex) : nullptr; if (!r || !*r) throw ConfigurationException("AttributeValueRegex MatchFunctor requires non-empty regex attribute."); try { - m_regex = new RegularExpression(r, e->getAttributeNS(nullptr,options)); + m_regex.reset(new RegularExpression(r, e->getAttributeNS(nullptr, options))); } catch (XMLException& ex) { xmltooling::auto_ptr_char temp(ex.getMessage()); @@ -72,9 +72,7 @@ namespace shibsp { } } - virtual ~AttributeValueRegexFunctor() { - delete m_regex; - } + virtual ~AttributeValueRegexFunctor() {} bool evaluatePolicyRequirement(const FilteringContext& filterContext) const { if (m_attributeID.empty()) @@ -89,7 +87,7 @@ namespace shibsp { } }; - MatchFunctor* SHIBSP_DLLLOCAL AttributeValueRegexFactory(const std::pair& p) + MatchFunctor* SHIBSP_DLLLOCAL AttributeValueRegexFactory(const pair& p) { return new AttributeValueRegexFunctor(p.second); } @@ -116,8 +114,6 @@ bool AttributeValueRegexFunctor::matches(const Attribute& attribute, size_t inde const char* val = attribute.getString(index); if (!val) return false; - XMLCh* temp = xmltooling::fromUTF8(val); - bool ret = m_regex->matches(temp); - delete[] temp; - return ret; + auto_arrayptr temp(fromUTF8(val)); + return m_regex->matches(temp.get()); }