summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-10-10 12:48:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-17 12:00:23 +0200
commitee3f06ad27b68b6b457d29ed7b2ab8c6d7d4db31 (patch)
treed280fdab55b77288a81cc09eaaacb9938f4d429f /xmloff
parentd9596a20b8b0664e5570e421184767e6edaa57bb (diff)
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@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlimp.cxx7
-rw-r--r--xmloff/source/style/xmlimppr.cxx3
2 files changed, 6 insertions, 4 deletions
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;
}