Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XmlFile is improperly changing escaped text in attributes #4971

Open
wixbot opened this issue Nov 20, 2015 · 2 comments
Open

XmlFile is improperly changing escaped text in attributes #4971

wixbot opened this issue Nov 20, 2015 · 2 comments

Comments

@wixbot
Copy link

wixbot commented Nov 20, 2015

Expected: util:XmlFile will leave attributes unchanged unless the ElementPath specifies those attributes as the target of the util:XmlFile operation, including attributes containing escaped values (e.g., ).

Observed: util:XmlFile changes all attributes in the target file so that escaped values are replaced with their unescaped equivalents.

Discussion:

I am using util:XmlFile with setValue to configure a log4net.config file; I'm using it to set the log file path and that works fine.

The problem is that elsewhere in the config file, I have this in the XML that is being modified by the util:XmlFile operation:

<header value="Timestamp&#x9;Thread&#x9;Level&#x9;Logger&#x9;Message&#xD;&#xA;" />

I would expect to see the same attribute in the output. However, after the util:XmlFile operation runs, it looks like this:

<header value="Timestamp  Thread  Level   Logger  Message
"/>

So you see that it is converting the &#x9;, &#xD; and &#xA; strings into their unescaped equivalents, and as a result, log4net doesn't do what I intended.


For completeness, here is the util:XmlFile element in my .wxs file; it's working fine as far as setting the desired attribute goes, but the problem is the side effects I've described:

<util:XmlFile Id="SetDefaultAppenderValueAttribute"
              Action="setValue"
              ElementPath="//log4net/appender[\[]@name='Default'[\]]/file"
              Name="value"
              Value="[DIR_PROGRAMDATA_MYPRODUCT]logs\MyProduct.log"
              File="[#FILE_MYPRODUCT_LOGGING_CONFIG]"
              Sequence="1" />

Also, here is the XML file that it is being deployed by the setup and modified by this util:XmlFile operation:

<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns="urn:log4net">
  <appender name="Default" type="log4net.Appender.RollingFileAppender">
    <threshold value="INFO" />
    <file value="MyProduct.log" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10MB" />
    <datePattern value=".yyyyMMdd'.log'" />
    <countDirection value="1" />
    <lockingModel value="log4net.Appender.FileAppender+MinimalLock" />
    <staticLogFileName value="true" />
    <preserveLogFileNameExtension value="false" />
    <layout type="log4net.Layout.PatternLayout">
      <header value="Timestamp&#x9;Thread&#x9;Level&#x9;Logger&#x9;Message&#xD;&#xA;" />
      <conversionPattern value="%date&#x9;%thread&#x9;%level&#x9;%logger&#x9;%message%newline" />
      <footer value="&#xD;&#xA;" />
    </layout>
  </appender>
</log4net>

Originally opened by hughbiquitous

@wixbot
Copy link
Author

wixbot commented Nov 20, 2015

MSXML is expanding those entities when rewriting the file. Might not be possible to fix without a new parser but needs investigation.

Release changed from v3.10 to v3.x

@wixbot
Copy link
Author

wixbot commented Nov 20, 2015

Fixed entities in defect; they got resolved to tab/CR/LF

Originally posted by hughbiquitous

@wixbot wixbot added this to the v3.x milestone Dec 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant