diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-02-28 21:28:55 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-03-02 09:51:55 +0100 |
commit | 1bd9fcafe67cac9404c8c96553a262c048802c25 (patch) | |
tree | cff22442b06f8c803ce641627324ad6f4489b7c9 | |
parent | 3d5a7631942171c2d73fbb172c2a9e7a50e9c3e3 (diff) |
tdf#115429 sax,xmloff: assert on empty attribute names & namespaces
Surely that's indication of a bug somewhere.
Change-Id: Ic6219d8eb7f22301d8c4da98b2132ae3ef0467b5
Reviewed-on: https://gerrit.libreoffice.org/50579
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 1 | ||||
-rw-r--r-- | sd/source/filter/xml/sdtransform.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/core/SvXMLAttrCollection.cxx | 12 |
3 files changed, 25 insertions, 1 deletions
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index fa91125b2245..a9f0baf7a2c0 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -80,6 +80,7 @@ void FastAttributeList::clear() void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength ) { + assert(nToken != -1); maAttributeTokens.push_back( nToken ); sal_Int32 nWritePosition = maAttributeValues.back(); maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 ); diff --git a/sd/source/filter/xml/sdtransform.cxx b/sd/source/filter/xml/sdtransform.cxx index c2ce55e066cd..e7d1ca8cc7a1 100644 --- a/sd/source/filter/xml/sdtransform.cxx +++ b/sd/source/filter/xml/sdtransform.cxx @@ -341,7 +341,18 @@ bool SdTransformOOo2xDocument::removeAlienAttributes( SfxItemSet& rSet, sal_uInt for( nItem = 0; nItem < nCount; nItem++ ) { if( nItem != nFound ) - aNewItem.AddAttr( rAttr.GetAttrPrefix(nItem),rAttr.GetAttrNamespace(nItem), rAttr.GetAttrLName(nItem), rAttr.GetAttrValue(nItem ) ); + { + OUString const& rNamespace(rAttr.GetAttrNamespace(nItem)); + OUString const& rPrefix(rAttr.GetAttrPrefix(nItem)); + if (rPrefix.isEmpty()) + { + aNewItem.AddAttr(rAttr.GetAttrLName(nItem), rAttr.GetAttrValue(nItem)); + } + else + { + aNewItem.AddAttr(rPrefix, rNamespace, rAttr.GetAttrLName(nItem), rAttr.GetAttrValue(nItem)); + } + } } rSet.Put( aNewItem ); diff --git a/xmloff/source/core/SvXMLAttrCollection.cxx b/xmloff/source/core/SvXMLAttrCollection.cxx index e203e3c9f920..fcb9a5b0dd9a 100644 --- a/xmloff/source/core/SvXMLAttrCollection.cxx +++ b/xmloff/source/core/SvXMLAttrCollection.cxx @@ -20,6 +20,7 @@ bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const bool SvXMLAttrCollection::AddAttr( const OUString& rLName, const OUString& rValue ) { + assert(!rLName.isEmpty()); aAttrs.emplace_back(rLName, rValue ); return true; } @@ -29,6 +30,9 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix, const OUString& rLName, const OUString& rValue ) { + assert(!rPrefix.isEmpty()); + assert(!rNamespace.isEmpty()); + assert(!rLName.isEmpty()); sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace ); aAttrs.emplace_back(nPos, rLName, rValue ); return true; @@ -38,6 +42,8 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix, const OUString& rLName, const OUString& rValue ) { + assert(!rPrefix.isEmpty()); + assert(!rLName.isEmpty()); sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix ); if( USHRT_MAX == nPos ) return false; @@ -49,6 +55,7 @@ bool SvXMLAttrCollection::SetAt( size_t i, const OUString& rLName, const OUString& rValue ) { + assert(!rLName.isEmpty()); if( i >= GetAttrCount() ) return false; aAttrs[i] = SvXMLAttr(rLName, rValue); @@ -61,6 +68,9 @@ bool SvXMLAttrCollection::SetAt( size_t i, const OUString& rLName, const OUString& rValue ) { + assert(!rPrefix.isEmpty()); + assert(!rNamespace.isEmpty()); + assert(!rLName.isEmpty()); if( i >= GetAttrCount() ) return false; @@ -77,6 +87,8 @@ bool SvXMLAttrCollection::SetAt( size_t i, const OUString& rLName, const OUString& rValue ) { + assert(!rPrefix.isEmpty()); + assert(!rLName.isEmpty()); if( i >= GetAttrCount() ) return false; |