diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-10-30 17:28:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-10-30 17:28:28 +0100 |
commit | 2b5ce52cddc16be5b3bb511b278bcfef3f706237 (patch) | |
tree | 56021bfe8ba04ca000f985c23bdfe84a1e41d08c /sal | |
parent | 86585175a607982f0549ddad19851f1ebf52148c (diff) |
Fix osl_getSystemPathFromFileURL URL scheme check
Change-Id: If7737b9eaf11333facd9ae3faf58e36ba76c3b05
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file_url.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 742b3f5a6a29..ee5f0382b6bc 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -32,6 +32,7 @@ #include <osl/thread.h> #include <osl/process.h> +#include <rtl/character.hxx> #include <rtl/uri.h> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.h> @@ -86,7 +87,6 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt rtl_uString * pTmp = NULL; sal_Unicode encodedSlash[3] = { '%', '2', 'F' }; - sal_Unicode protocolDelimiter[3] = { ':', '/', '/' }; /* a valid file url may not start with '/' */ 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; } - /* Check for non file:// protocols */ - - nIndex = rtl_ustr_indexOfStr_WithLength( ustrFileURL->buffer, ustrFileURL->length, protocolDelimiter, 3 ); - if ( -1 != nIndex && (4 != nIndex || 0 != rtl_ustr_ascii_shortenedCompare_WithLength( ustrFileURL->buffer, ustrFileURL->length,"file", 4 ) ) ) - { - return osl_File_E_INVAL; + // Check for non file scheme: + if (rtl::isAsciiAlpha(ustrFileURL->buffer[0])) { + for (sal_Int32 i = 1; i != ustrFileURL->length; ++i) { + auto c = ustrFileURL->buffer[i]; + if (c == ':') { + 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 */ |