Use osl_getEnvironment instead of getenv
Avoids conversion to OUString; and is Unicode-safe on Windows. Change-Id: Idd82f589ae9bf692ce2e73f84cb664a68156915a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183507 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include <rtl/bootstrap.hxx>
|
#include <rtl/bootstrap.hxx>
|
||||||
#include <rtl/string.hxx>
|
#include <rtl/string.hxx>
|
||||||
#include <osl/file.hxx>
|
#include <osl/file.hxx>
|
||||||
|
#include <osl/process.h>
|
||||||
#include <osl/thread.h>
|
#include <osl/thread.h>
|
||||||
#include <sal/log.hxx>
|
#include <sal/log.hxx>
|
||||||
#include <comphelper/diagnose_ex.hxx>
|
#include <comphelper/diagnose_ex.hxx>
|
||||||
@@ -176,13 +177,13 @@ const OUString & ONSSInitializer::getMozillaCurrentProfile(const css::uno::Refer
|
|||||||
m_bIsNSSinitialized = true;
|
m_bIsNSSinitialized = true;
|
||||||
|
|
||||||
// first, try to get the profile from "MOZILLA_CERTIFICATE_FOLDER"
|
// first, try to get the profile from "MOZILLA_CERTIFICATE_FOLDER"
|
||||||
const char* pEnv = getenv("MOZILLA_CERTIFICATE_FOLDER");
|
if (OUString pEnv; osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData) == osl_Process_E_None
|
||||||
if (pEnv)
|
&& !pEnv.isEmpty())
|
||||||
{
|
{
|
||||||
SAL_INFO(
|
SAL_INFO(
|
||||||
"xmlsecurity.xmlsec",
|
"xmlsecurity.xmlsec",
|
||||||
"Using Mozilla profile from MOZILLA_CERTIFICATE_FOLDER=" << pEnv);
|
"Using Mozilla profile from MOZILLA_CERTIFICATE_FOLDER=" << pEnv);
|
||||||
m_sNSSPath = OStringToOUString(pEnv, osl_getThreadTextEncoding());
|
m_sNSSPath = pEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// second, try to get saved user-preference
|
// second, try to get saved user-preference
|
||||||
@@ -284,9 +285,10 @@ css::uno::Sequence<css::xml::crypto::NSSProfile> SAL_CALL ONSSInitializer::getNS
|
|||||||
}
|
}
|
||||||
aProfileList.push_back({u"MANUAL"_ustr, sUserSelect, mozilla::MozillaProductType_Default});
|
aProfileList.push_back({u"MANUAL"_ustr, sUserSelect, mozilla::MozillaProductType_Default});
|
||||||
|
|
||||||
const char* pEnv = getenv("MOZILLA_CERTIFICATE_FOLDER");
|
OUString pEnv;
|
||||||
|
osl_getEnvironment(u"MOZILLA_CERTIFICATE_FOLDER"_ustr.pData, &pEnv.pData);
|
||||||
aProfileList.push_back({u"MOZILLA_CERTIFICATE_FOLDER"_ustr,
|
aProfileList.push_back({u"MOZILLA_CERTIFICATE_FOLDER"_ustr,
|
||||||
pEnv ? OStringToOUString(pEnv, osl_getThreadTextEncoding()) : OUString(),
|
pEnv,
|
||||||
mozilla::MozillaProductType_Default});
|
mozilla::MozillaProductType_Default});
|
||||||
|
|
||||||
return comphelper::containerToSequence(aProfileList);
|
return comphelper::containerToSequence(aProfileList);
|
||||||
|
Reference in New Issue
Block a user