Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: .NET security update broke transform engine?

From: APA <buddy__a@-------.--->
To: NULL
Date: 7/14/2007 3:18:00 PM

OK, my StreamReader was not being set to the encoding of the Tranform OutputSetting Encoding.  I was using this:

             MemoryStream ms = new MemoryStream();
             m_Transform.Transform(XmlData, TransformArgumentList, ms);
             ms.Position = 0;
             StreamReader sr = new StreamReader(ms);

So, something changed in this update because the server without the update was using UTF-8 encoding on the streamreader and it caused character 160 to 
essentially be stripped in the output.  On the server with the update it converted character 160 to 0xFFFD.  So, I corrected my StreamReader but 
something definitely changed in the update.  The transform was transforming to ISO-8859-1 then the streamreader was converting it to UTF-8, previously 
that was stripping character 160 from the output and now it converts it to character 0xFFFD.




Martin Honnen wrote:
> APA wrote:
>> I didn't say I was using the XslTransform class, I was generically 
>> referring to the XslTransform engine in .NET (and this is a .NET 2.0 
>> application).  The issue is clearly a problem with the update as my 
>> server that does not have the update doesn't produce the bad output 
>> but the one with it does.
>>
>> Here's a real simple example that produces the bad output.
>>
>>
>>         <xsl:stylesheet version="1.0" 
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>             <xsl:output method="html" omit-xml-declaration="no"  
>> encoding="ISO-8859-1" />
>>
>>             <xsl:template match="/">
>>                 <b>&#0160;</b>
>>             </xsl:template>
>>
>>         </xsl:stylesheet>
>>
>>
>> This generates character xFFFD in the output where it produced a 
>> proper space character previously.
> 
> I have a Windows XP system here that on Wednesday got the security 
> update for KB928365. Using your stylesheet I made the following complete 
> test case
> 
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.IO;
> using System.Xml;
> using System.Xml.Xsl;
> 
> namespace ConsoleApplication106
> {
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             XslCompiledTransform xsltProcessor = new 
> XslCompiledTransform();
>             xsltProcessor.Load(XmlReader.Create(new 
> StringReader(@"<xsl:stylesheet 
> xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""1.0"">
> <xsl:output method=""html"" indent=""no"" encoding=""ISO-8859-1""/>
> <xsl:template match=""/""><b>&#160;</b></xsl:template>
> </xsl:stylesheet>")));
>             MemoryStream memStream = new MemoryStream();
>             xsltProcessor.Transform(XmlReader.Create(new 
> StringReader(@"<dummy/>")), null, memStream);
>             memStream.Position = 0;
>             StreamReader streamReader = new StreamReader(memStream, 
> xsltProcessor.OutputSettings.Encoding);
>             string contents = streamReader.ReadToEnd();
>             streamReader.Close();
>             foreach (char c in contents)
>             {
>                 Console.WriteLine("Character '{0}' with codepoint {1}.", 
> c, (int)c);
>             }
>         }
>     }
> }
> 
> The output on the console is
> 
> Character '<' with codepoint 60.
> Character 'b' with codepoint 98.
> Character '>' with codepoint 62.
> Character ' ' with codepoint 160.
> Character '<' with codepoint 60.
> Character '/' with codepoint 47.
> Character 'b' with codepoint 98.
> Character '>' with codepoint 62.
> 
> so the non-breaking space (character 160) is correctly included in the 
> output.
> 
> I can't reproduce the problem you describe.
> 
> 


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent