use more string_view in svl
Change-Id: I9b6a074eb6342808d02a69f3ed1fa713e81d2608 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132958 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -252,7 +252,7 @@ public:
|
|||||||
|
|
||||||
static INetContentType GetContentTypeFromURL(OUString const& rURL);
|
static INetContentType GetContentTypeFromURL(OUString const& rURL);
|
||||||
|
|
||||||
static bool GetExtensionFromURL(OUString const& rURL, OUString& rExtension);
|
static bool GetExtensionFromURL(std::u16string_view rURL, OUString& rExtension);
|
||||||
|
|
||||||
static bool parse(OUString const& rMediaType, OUString& rType, OUString& rSubType,
|
static bool parse(OUString const& rMediaType, OUString& rType, OUString& rSubType,
|
||||||
INetContentTypeParameterList* pParameters = nullptr);
|
INetContentTypeParameterList* pParameters = nullptr);
|
||||||
|
@@ -392,26 +392,26 @@ INetContentType INetContentTypes::GetContentTypeFromURL(OUString const & rURL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
bool INetContentTypes::GetExtensionFromURL(OUString const & rURL,
|
bool INetContentTypes::GetExtensionFromURL(std::u16string_view rURL,
|
||||||
OUString & rExtension)
|
OUString & rExtension)
|
||||||
{
|
{
|
||||||
sal_Int32 nSlashPos = 0;
|
size_t nSlashPos = 0;
|
||||||
sal_Int32 i = 0;
|
size_t i = 0;
|
||||||
while (i >= 0)
|
while (i != std::u16string_view::npos)
|
||||||
{
|
{
|
||||||
nSlashPos = i;
|
nSlashPos = i;
|
||||||
i = rURL.indexOf('/', i + 1);
|
i = rURL.find('/', i + 1);
|
||||||
}
|
}
|
||||||
if (nSlashPos != 0)
|
if (nSlashPos != 0)
|
||||||
{
|
{
|
||||||
sal_Int32 nLastDotPos = i = rURL.indexOf('.', nSlashPos);
|
size_t nLastDotPos = i = rURL.find('.', nSlashPos);
|
||||||
while (i >= 0)
|
while (i != std::u16string_view::npos)
|
||||||
{
|
{
|
||||||
nLastDotPos = i;
|
nLastDotPos = i;
|
||||||
i = rURL.indexOf('.', i + 1);
|
i = rURL.find('.', i + 1);
|
||||||
}
|
}
|
||||||
if (nLastDotPos >- 0)
|
if (nLastDotPos >- 0)
|
||||||
rExtension = rURL.copy(nLastDotPos + 1);
|
rExtension = rURL.substr(nLastDotPos + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -412,7 +412,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
|
std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view aLine, std::u16string_view aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
|
||||||
{
|
{
|
||||||
if( !aMasterPasswd.isEmpty() )
|
if( !aMasterPasswd.isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -428,10 +428,13 @@ std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view
|
|||||||
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
|
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
|
||||||
|
|
||||||
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
|
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
|
||||||
if (!aIV.isEmpty())
|
if (!aIV.empty())
|
||||||
{
|
{
|
||||||
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
|
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
|
||||||
iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16));
|
{
|
||||||
|
auto tmp = aIV.substr( ind*2, 2 );
|
||||||
|
iv[ ind ] = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtlCipherError result = rtl_cipher_init (
|
rtlCipherError result = rtl_cipher_init (
|
||||||
@@ -469,7 +472,7 @@ std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view
|
|||||||
"Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode);
|
"Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPasswd)
|
OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, std::u16string_view aIV, const OUString& aMasterPasswd)
|
||||||
{
|
{
|
||||||
if( !aMasterPasswd.isEmpty() )
|
if( !aMasterPasswd.isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -487,10 +490,13 @@ OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines
|
|||||||
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
|
code[ ind ] = static_cast<char>(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
|
||||||
|
|
||||||
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
|
unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0};
|
||||||
if (!aIV.isEmpty())
|
if (!aIV.empty())
|
||||||
{
|
{
|
||||||
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
|
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
|
||||||
iv[ ind ] = static_cast<char>(aIV.copy( ind*2, 2 ).toUInt32(16));
|
{
|
||||||
|
auto tmp = aIV.substr( ind*2, 2 );
|
||||||
|
iv[ ind ] = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtlCipherError result = rtl_cipher_init (
|
rtlCipherError result = rtl_cipher_init (
|
||||||
@@ -837,12 +843,13 @@ OUString PasswordContainer::RequestPasswordFromUser( PasswordRequestMode aRMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mangle the key to match an old bug
|
// Mangle the key to match an old bug
|
||||||
static OUString ReencodeAsOldHash(const OUString& rPass)
|
static OUString ReencodeAsOldHash(std::u16string_view rPass)
|
||||||
{
|
{
|
||||||
OUStringBuffer aBuffer;
|
OUStringBuffer aBuffer;
|
||||||
for (int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ++ind)
|
for (int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ++ind)
|
||||||
{
|
{
|
||||||
unsigned char i = static_cast<char>(rPass.copy(ind * 2, 2).toUInt32(16));
|
auto tmp = rPass.substr(ind * 2, 2);
|
||||||
|
unsigned char i = static_cast<char>(rtl_ustr_toInt64_WithLength(tmp.data(), 16, tmp.size()));
|
||||||
aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4)));
|
aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4)));
|
||||||
aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15)));
|
aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15)));
|
||||||
}
|
}
|
||||||
|
@@ -316,10 +316,10 @@ private:
|
|||||||
const css::uno::Reference< css::task::XInteractionHandler >& Handler );
|
const css::uno::Reference< css::task::XInteractionHandler >& Handler );
|
||||||
|
|
||||||
/// @throws css::uno::RuntimeException
|
/// @throws css::uno::RuntimeException
|
||||||
static ::std::vector< OUString > DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
|
static ::std::vector< OUString > DecodePasswords( std::u16string_view aLine, std::u16string_view aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
|
||||||
|
|
||||||
/// @throws css::uno::RuntimeException
|
/// @throws css::uno::RuntimeException
|
||||||
static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPassword );
|
static OUString EncodePasswords(const std::vector< OUString >& lines, std::u16string_view aIV, const OUString& aMasterPassword );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PasswordContainer( const css::uno::Reference< css::uno::XComponentContext >& );
|
PasswordContainer( const css::uno::Reference< css::uno::XComponentContext >& );
|
||||||
|
Reference in New Issue
Block a user