[REVIEW-3-5] fdo#42961 Don't let env vars interfere with internal bootstrap vars

Stephan Bergmann sbergman at redhat.com
Thu Mar 15 01:53:56 PDT 2012


Please consider the below fix for 
<https://bugs.freedesktop.org/show_bug.cgi?id=42961> "Setting $DATA 
causes LibreOffice to crash" for inclusion in libreoffice-3-5.  Not sure 
it is worth it including it in libreoffice-3-4 (the bug should be in at 
least since OOo 3.3).

Stephan

On 03/15/2012 09:48 AM, Stephan Bergmann wrote:
> commit 84ecea9655267afc266b79059baa4512a285b1f2
> Author: Stephan Bergmann<sbergman at redhat.com>
> Date:   Thu Mar 15 09:34:56 2012 +0100
>
>      fdo#42961 Don't let env vars interfere with internal bootstrap vars
>
> diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
> index 0e1c7e4..6f18508 100644
> --- a/configmgr/source/components.cxx
> +++ b/configmgr/source/components.cxx
> @@ -53,6 +53,7 @@
>   #include "rtl/oustringostreaminserter.hxx"
>   #include "rtl/ref.hxx"
>   #include "rtl/string.h"
> +#include "rtl/ustrbuf.hxx"
>   #include "rtl/ustring.h"
>   #include "rtl/ustring.hxx"
>   #include "rtl/instance.hxx"
> @@ -827,17 +828,38 @@ void Components::parseXcsXcuLayer(int layer, rtl::OUString const&  url) {
>   void Components::parseXcsXcuIniLayer(
>       int layer, rtl::OUString const&  url, bool recordAdditions)
>   {
> -    //TODO: rtl::Bootstrap::getFrom "first trie[s] to retrieve the value via the
> -    // global function"
> +    // Check if ini file exists (otherwise .override would still read global
> +    // SCHEMA/DATA variables, which could interfere with unrelated environment
> +    // variables):
>       rtl::Bootstrap ini(url);
> -    rtl::OUString urls;
> -    if (ini.getFrom(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SCHEMA")), urls))
> +    if (ini.getHandle() != 0)
>       {
> -        parseFileList(layer,&parseXcsFile, urls, ini, false);
> -    }
> -    if (ini.getFrom(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA")), urls))
> -    {
> -        parseFileList(layer + 1,&parseXcuFile, urls, ini, recordAdditions);
> +        rtl::OUStringBuffer prefix("${.override:");
> +        for (sal_Int32 i = 0; i != url.getLength(); ++i) {
> +            sal_Unicode c = url[i];
> +            switch (c) {
> +            case '$':
> +            case ':':
> +            case '\\':
> +                prefix.append('\\');
> +                // fall through
> +            default:
> +                prefix.append(c);
> +            }
> +        }
> +        prefix.append(':');
> +        rtl::OUString urls(prefix.toString() + rtl::OUString("SCHEMA}"));
> +        rtl::Bootstrap::expandMacros(urls);
> +        if (!urls.isEmpty())
> +        {
> +            parseFileList(layer,&parseXcsFile, urls, ini, false);
> +        }
> +        urls = prefix.makeStringAndClear() + rtl::OUString("DATA}");
> +        rtl::Bootstrap::expandMacros(urls);
> +        if (!urls.isEmpty())
> +        {
> +            parseFileList(layer + 1,&parseXcuFile, urls, ini, recordAdditions);
> +        }
>       }
>   }


More information about the LibreOffice mailing list