tdf#100783 Avoid infinite recursion in Content::getObject()
With certain CMIS host URLs, it is possible that exception handler in Content::getObject() will recursively call itself with the same data (xParent from the same URL). This patch checks if the new URL is not the same as own, to avoid this. Change-Id: Ifaeb4ff27a9c809c5c96fa35ec190c3263a8fe62 Reviewed-on: https://gerrit.libreoffice.org/26977 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
This commit is contained in:
committed by
Andras Timar
parent
a389012950
commit
d1a32a01be
@@ -538,17 +538,20 @@ namespace cmis
|
|||||||
string sName = OUSTR_TO_STDSTR( aParentUrl.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ) );
|
string sName = OUSTR_TO_STDSTR( aParentUrl.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ) );
|
||||||
aParentUrl.removeSegment( );
|
aParentUrl.removeSegment( );
|
||||||
OUString sParentUrl = aParentUrl.GetMainURL( INetURLObject::NO_DECODE );
|
OUString sParentUrl = aParentUrl.GetMainURL( INetURLObject::NO_DECODE );
|
||||||
|
// Avoid infinite recursion if sParentUrl == m_sURL
|
||||||
rtl::Reference<Content> xParent( new Content(m_xContext, m_pProvider, new ucbhelper::ContentIdentifier( sParentUrl )) );
|
if (sParentUrl != m_sURL)
|
||||||
libcmis::FolderPtr pParentFolder = boost::dynamic_pointer_cast< libcmis::Folder >( xParent->getObject( xEnv ) );
|
|
||||||
if ( pParentFolder )
|
|
||||||
{
|
{
|
||||||
vector< libcmis::ObjectPtr > children = pParentFolder->getChildren( );
|
rtl::Reference<Content> xParent(new Content(m_xContext, m_pProvider, new ucbhelper::ContentIdentifier(sParentUrl)));
|
||||||
for ( vector< libcmis::ObjectPtr >::iterator it = children.begin( );
|
libcmis::FolderPtr pParentFolder = boost::dynamic_pointer_cast< libcmis::Folder >(xParent->getObject(xEnv));
|
||||||
it != children.end() && !m_pObject; ++it )
|
if (pParentFolder)
|
||||||
{
|
{
|
||||||
if ( ( *it )->getName( ) == sName )
|
vector< libcmis::ObjectPtr > children = pParentFolder->getChildren();
|
||||||
m_pObject = *it;
|
for (vector< libcmis::ObjectPtr >::iterator it = children.begin();
|
||||||
|
it != children.end() && !m_pObject; ++it)
|
||||||
|
{
|
||||||
|
if ((*it)->getName() == sName)
|
||||||
|
m_pObject = *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user