Kaydet (Commit) 1bd9fcaf authored tarafından Michael Stahl's avatar Michael Stahl

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/50579Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 3d5a7631
...@@ -80,6 +80,7 @@ void FastAttributeList::clear() ...@@ -80,6 +80,7 @@ void FastAttributeList::clear()
void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength ) void FastAttributeList::add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength )
{ {
assert(nToken != -1);
maAttributeTokens.push_back( nToken ); maAttributeTokens.push_back( nToken );
sal_Int32 nWritePosition = maAttributeValues.back(); sal_Int32 nWritePosition = maAttributeValues.back();
maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 ); maAttributeValues.push_back( maAttributeValues.back() + nValueLength + 1 );
......
...@@ -341,7 +341,18 @@ bool SdTransformOOo2xDocument::removeAlienAttributes( SfxItemSet& rSet, sal_uInt ...@@ -341,7 +341,18 @@ bool SdTransformOOo2xDocument::removeAlienAttributes( SfxItemSet& rSet, sal_uInt
for( nItem = 0; nItem < nCount; nItem++ ) for( nItem = 0; nItem < nCount; nItem++ )
{ {
if( nItem != nFound ) 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 ); rSet.Put( aNewItem );
......
...@@ -20,6 +20,7 @@ bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const ...@@ -20,6 +20,7 @@ bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const
bool SvXMLAttrCollection::AddAttr( const OUString& rLName, bool SvXMLAttrCollection::AddAttr( const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rLName.isEmpty());
aAttrs.emplace_back(rLName, rValue ); aAttrs.emplace_back(rLName, rValue );
return true; return true;
} }
...@@ -29,6 +30,9 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix, ...@@ -29,6 +30,9 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rLName, const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rPrefix.isEmpty());
assert(!rNamespace.isEmpty());
assert(!rLName.isEmpty());
sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace ); sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
aAttrs.emplace_back(nPos, rLName, rValue ); aAttrs.emplace_back(nPos, rLName, rValue );
return true; return true;
...@@ -38,6 +42,8 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix, ...@@ -38,6 +42,8 @@ bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rLName, const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rPrefix.isEmpty());
assert(!rLName.isEmpty());
sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix ); sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
if( USHRT_MAX == nPos ) if( USHRT_MAX == nPos )
return false; return false;
...@@ -49,6 +55,7 @@ bool SvXMLAttrCollection::SetAt( size_t i, ...@@ -49,6 +55,7 @@ bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rLName, const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rLName.isEmpty());
if( i >= GetAttrCount() ) if( i >= GetAttrCount() )
return false; return false;
aAttrs[i] = SvXMLAttr(rLName, rValue); aAttrs[i] = SvXMLAttr(rLName, rValue);
...@@ -61,6 +68,9 @@ bool SvXMLAttrCollection::SetAt( size_t i, ...@@ -61,6 +68,9 @@ bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rLName, const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rPrefix.isEmpty());
assert(!rNamespace.isEmpty());
assert(!rLName.isEmpty());
if( i >= GetAttrCount() ) if( i >= GetAttrCount() )
return false; return false;
...@@ -77,6 +87,8 @@ bool SvXMLAttrCollection::SetAt( size_t i, ...@@ -77,6 +87,8 @@ bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rLName, const OUString& rLName,
const OUString& rValue ) const OUString& rValue )
{ {
assert(!rPrefix.isEmpty());
assert(!rLName.isEmpty());
if( i >= GetAttrCount() ) if( i >= GetAttrCount() )
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment