diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 12:31:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 14:58:51 +0200 |
commit | 29489b33b435683021b72cb2bce27aba8cb7a430 (patch) | |
tree | 8e4e1c59d56d5ed0d0ca4d088419067041e4553a /xmlsecurity | |
parent | a4244c0f05b95ded277a3a7ed217bf0451daa996 (diff) |
loplugin:flatten
Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/helper/ooxmlsecparser.cxx | 40 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecparser.cxx | 41 |
2 files changed, 39 insertions, 42 deletions
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx index a4e46951bf51..2692190ccb89 100644 --- a/xmlsecurity/source/helper/ooxmlsecparser.cxx +++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx @@ -373,21 +373,21 @@ class OOXMLSecParser::DsDigestMethodContext OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); - if (!ouAlgorithm.isEmpty()) - { - SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 - && ouAlgorithm != ALGO_XMLDSIGSHA256 - && ouAlgorithm != ALGO_XMLDSIGSHA512, - "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); - if (ouAlgorithm == ALGO_XMLDSIGSHA1) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; - else if (ouAlgorithm == ALGO_XMLDSIGSHA256) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; - else if (ouAlgorithm == ALGO_XMLDSIGSHA512) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; - else - m_rReferenceDigestID = 0; - } + if (ouAlgorithm.isEmpty()) + return; + + SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 + && ouAlgorithm != ALGO_XMLDSIGSHA256 + && ouAlgorithm != ALGO_XMLDSIGSHA512, + "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); + if (ouAlgorithm == ALGO_XMLDSIGSHA1) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; + else if (ouAlgorithm == ALGO_XMLDSIGSHA256) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; + else if (ouAlgorithm == ALGO_XMLDSIGSHA512) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; + else + m_rReferenceDigestID = 0; } }; @@ -1272,17 +1272,15 @@ void SAL_CALL OOXMLSecParser::startElement(const OUString& rName, const uno::Ref if (m_ContextStack.empty()) { - if (nPrefix == XML_NAMESPACE_DS - && localName == "Signature") - { - pContext.reset(new DsSignatureContext(*this, std::move(pRewindMap))); - } - else + if (nPrefix != XML_NAMESPACE_DS || localName != "Signature") { throw css::xml::sax::SAXException( "xmlsecurity: unexpected root element", nullptr, css::uno::Any()); } + + pContext.reset(new DsSignatureContext(*this, std::move(pRewindMap))); + } else { diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx index b31f961e3548..af3562f46c40 100644 --- a/xmlsecurity/source/helper/xsecparser.cxx +++ b/xmlsecurity/source/helper/xsecparser.cxx @@ -492,21 +492,21 @@ class XSecParser::DsDigestMethodContext OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); - if (!ouAlgorithm.isEmpty()) - { - SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 - && ouAlgorithm != ALGO_XMLDSIGSHA256 - && ouAlgorithm != ALGO_XMLDSIGSHA512, - "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); - if (ouAlgorithm == ALGO_XMLDSIGSHA1) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; - else if (ouAlgorithm == ALGO_XMLDSIGSHA256) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; - else if (ouAlgorithm == ALGO_XMLDSIGSHA512) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; - else - m_rReferenceDigestID = 0; - } + if (ouAlgorithm.isEmpty()) + return; + + SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 + && ouAlgorithm != ALGO_XMLDSIGSHA256 + && ouAlgorithm != ALGO_XMLDSIGSHA512, + "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); + if (ouAlgorithm == ALGO_XMLDSIGSHA1) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; + else if (ouAlgorithm == ALGO_XMLDSIGSHA256) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; + else if (ouAlgorithm == ALGO_XMLDSIGSHA512) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; + else + m_rReferenceDigestID = 0; } }; @@ -1508,17 +1508,16 @@ void SAL_CALL XSecParser::startElement( if (m_ContextStack.empty()) { - if ((nPrefix == XML_NAMESPACE_DSIG || nPrefix == XML_NAMESPACE_DSIG_OOO) - && localName == "document-signatures") - { - pContext.reset(new DsigSignaturesContext(*this, std::move(pRewindMap))); - } - else + if ((nPrefix != XML_NAMESPACE_DSIG && nPrefix != XML_NAMESPACE_DSIG_OOO) + || localName != "document-signatures") { throw css::xml::sax::SAXException( "xmlsecurity: unexpected root element", nullptr, css::uno::Any()); } + + pContext.reset(new DsigSignaturesContext(*this, std::move(pRewindMap))); + } else { |