Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-370

There are Mistakes in Property Value which Contains Environment Variables, which Values Contain multibyte characters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 0.10.0
    • Fix Version/s: None
    • Component/s: Configurator
    • Labels:
      None
    • Environment:
      Windows XP SP2
      VC8.0SP1

      Description

      If the properties configuration file contains environment variables in the properties, such as log4j.appender.xxx.File, and the environment variables contain multbyte characters, such as Chinese characters, the values read are not the correct ones.

      Analyse
      When log4cxx loading properties configuration file, the environment variables in the properties will be replaced by actual values. This is implied by calling apr_env_get, which will convert the value to utf8.

      size = GetEnvironmentVariableW(wenvvar, wvalue, size);

      inchars = wcslen(wvalue) + 1;
      outchars = 3 * inchars; /* Enough for any UTF-8 representation */
      val = apr_palloc(pool, outchars);
      status = apr_conv_ucs2_to_utf8(wvalue, &inchars, val, &outchars);

      Then log4cxx::System::getProperty will call log4cxx::Transcoder::decode to convert the value to wide characters, which will call log4cxx::Transcoder::decode.
      There is a same problem with issue LOGCXX-369.
      Also the source string is utf8 encoded, and will not convert to wide character correctly.
      These mistakes lead an wrong file path for property log4j.appender.xxx.File.

      For example, the property value is "${ABC}/Log/STC.log", and the environment value is "D:\Temp\中文文件夹\STC".
      The property value which log4cxx got is "D:\Temp\涓枃鏂囦欢澶筡STC跺す\STCTC/Log/STC.log".

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                carnold@apache.org Curt Arnold
                Reporter:
                starwalker Starwalker
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: