summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorMikhail Voytenko <mav@openoffice.org>2010-08-10 11:05:20 +0200
committerMikhail Voytenko <mav@openoffice.org>2010-08-10 11:05:20 +0200
commit823d3cc493c8654a294ff45329c0514d2cc953d3 (patch)
tree90c3010937e7f2c0a7a3ab0e97d30513f96a055c /comphelper/source
parent06d8dc602fb3fa13f768044dc0b8058eb7b393c2 (diff)
mav56: #163253# tread invalid path segments correctly
Diffstat (limited to 'comphelper/source')
-rw-r--r--comphelper/source/misc/storagehelper.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index e2557523f674..db5ba71cd876 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -452,5 +452,36 @@ sal_Bool OStorageHelper::IsValidZipEntryFileName(
return sal_True;
}
+// ----------------------------------------------------------------------
+sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::rtl::OUString& aSegment )
+{
+ sal_Bool bResult = sal_False;
+ const sal_Int32 nPathLen = aPath.getLength();
+ const sal_Int32 nSegLen = aSegment.getLength();
+
+ if ( nSegLen && nPathLen >= nSegLen )
+ {
+ ::rtl::OUString aEndSegment( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ aEndSegment += aSegment;
+
+ ::rtl::OUString aInternalSegment( aEndSegment );
+ aInternalSegment += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+
+ if ( aPath.indexOf( aInternalSegment ) >= 0 )
+ bResult = sal_True;
+
+ if ( !bResult && !aPath.compareTo( aSegment, nSegLen ) )
+ {
+ if ( nPathLen == nSegLen || aPath.getStr()[nSegLen] == (sal_Unicode)'/' )
+ bResult = sal_True;
+ }
+
+ if ( !bResult && nPathLen > nSegLen && aPath.copy( nPathLen - nSegLen - 1, nSegLen + 1 ).equals( aEndSegment ) )
+ bResult = sal_True;
+ }
+
+ return bResult;
+}
+
}