Fix osl_getSystemPathFromFileURL URL scheme check
Change-Id: If7737b9eaf11333facd9ae3faf58e36ba76c3b05
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <osl/thread.h>
|
#include <osl/thread.h>
|
||||||
#include <osl/process.h>
|
#include <osl/process.h>
|
||||||
|
|
||||||
|
#include <rtl/character.hxx>
|
||||||
#include <rtl/uri.h>
|
#include <rtl/uri.h>
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
#include <rtl/ustrbuf.h>
|
#include <rtl/ustrbuf.h>
|
||||||
@@ -86,7 +87,6 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt
|
|||||||
rtl_uString * pTmp = NULL;
|
rtl_uString * pTmp = NULL;
|
||||||
|
|
||||||
sal_Unicode encodedSlash[3] = { '%', '2', 'F' };
|
sal_Unicode encodedSlash[3] = { '%', '2', 'F' };
|
||||||
sal_Unicode protocolDelimiter[3] = { ':', '/', '/' };
|
|
||||||
|
|
||||||
/* a valid file url may not start with '/' */
|
/* a valid file url may not start with '/' */
|
||||||
if( ( 0 == ustrFileURL->length ) || ( '/' == ustrFileURL->buffer[0] ) )
|
if( ( 0 == ustrFileURL->length ) || ( '/' == ustrFileURL->buffer[0] ) )
|
||||||
@@ -94,12 +94,25 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt
|
|||||||
return osl_File_E_INVAL;
|
return osl_File_E_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for non file:// protocols */
|
// Check for non file scheme:
|
||||||
|
if (rtl::isAsciiAlpha(ustrFileURL->buffer[0])) {
|
||||||
nIndex = rtl_ustr_indexOfStr_WithLength( ustrFileURL->buffer, ustrFileURL->length, protocolDelimiter, 3 );
|
for (sal_Int32 i = 1; i != ustrFileURL->length; ++i) {
|
||||||
if ( -1 != nIndex && (4 != nIndex || 0 != rtl_ustr_ascii_shortenedCompare_WithLength( ustrFileURL->buffer, ustrFileURL->length,"file", 4 ) ) )
|
auto c = ustrFileURL->buffer[i];
|
||||||
{
|
if (c == ':') {
|
||||||
return osl_File_E_INVAL;
|
if (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
|
||||||
|
ustrFileURL->buffer, i,
|
||||||
|
RTL_CONSTASCII_STRINGPARAM("file"))
|
||||||
|
!= 0)
|
||||||
|
{
|
||||||
|
return osl_File_E_INVAL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else if (!rtl::isAsciiAlphanumeric(c) && c != '+' && c != '-'
|
||||||
|
&& c != '.')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search for encoded slashes (%2F) and decode every single token if we find one */
|
/* search for encoded slashes (%2F) and decode every single token if we find one */
|
||||||
|
Reference in New Issue
Block a user