[Libreoffice-commits] core.git: xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Oct 17 10:01:03 UTC 2020


 xmloff/source/core/xmlimp.cxx    |    7 ++++---
 xmloff/source/style/xmlimppr.cxx |    3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit ee3f06ad27b68b6b457d29ed7b2ab8c6d7d4db31
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Oct 10 12:48:54 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Oct 17 12:00:23 2020 +0200

    fix fastparser namespace handling when...
    
    dealing with unknown attributes, in
    
        SvXMLLegacyToFastDocHandler::startElement
        SvXMLImportPropertyMapper::importXML
    
    which show up with some work I'm doing to make SvXMLImport fastparser-only.
    
    Change-Id: I71197c1659a5f072c2b186892be1f88ca6b2a764
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104140
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 2aeda90fc229..e56448adabd2 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -2261,12 +2261,13 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName,
         OUString aNamespace;
         const OUString& rAttrName = xAttrList->getNameByIndex( i );
         const OUString& rAttrValue = xAttrList->getValueByIndex( i );
-        sal_uInt16 const nAttrPrefix(mrImport->mpNamespaceMap->GetKeyByAttrName(
-                rAttrName, nullptr, &aLocalAttrName, &aNamespace));
+        // don't add unknown namespaces to the map
+        sal_uInt16 const nAttrPrefix = mrImport->mpNamespaceMap->GetKeyByQName(
+                rAttrName, nullptr, &aLocalAttrName, &aNamespace, SvXMLNamespaceMap::QNameMode::AttrValue);
         if( XML_NAMESPACE_XMLNS != nAttrPrefix )
         {
             auto const nToken = SvXMLImport::getTokenFromName(aLocalAttrName);
-            if (nToken == xmloff::XML_TOKEN_INVALID)
+            if (XML_NAMESPACE_UNKNOWN == nAttrPrefix || nToken == xmloff::XML_TOKEN_INVALID)
             {
                 mxFastAttributes->addUnknown(aNamespace,
                     OUStringToOString(rAttrName, RTL_TEXTENCODING_UTF8),
diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx
index a0886b18bd2d..0b327c73e6cc 100644
--- a/xmloff/source/style/xmlimppr.cxx
+++ b/xmloff/source/style/xmlimppr.cxx
@@ -147,7 +147,8 @@ void SvXMLImportPropertyMapper::importXML(
         {
             // If it's an unknown attribute in a known namespace, ignore it.
             OUString aPrefix = rAttribute.Name.copy(0, nSepIndex);
-            if (rNamespaceMap.GetKeyByPrefix(aPrefix) != USHRT_MAX)
+            auto nKey = rNamespaceMap.GetKeyByPrefix(aPrefix);
+            if (nKey != USHRT_MAX && !(nKey & XML_NAMESPACE_UNKNOWN_FLAG))
                 continue;
         }
 


More information about the Libreoffice-commits mailing list