or " /> or " /> or "/>

string encoded with AntiXssEncoder does not return correct value for Contains "
"

282 Views Asked by At

I have a string that was encoded with AntiXssEncoder

"Some text,\r\n\r&#1​0;Another text .\r\n\r\nThird text "

I want to replace &#1​0; with <br/> or \n for new line, but when I check if string contains

"&#1​0;" result in false,

Also Replace("&#1​0;","<br/>") does not replace anything

enter image description here

1

There are 1 best solutions below

0
P4ND4 On

Are you sure, you're not just throwing the generated string away returned by .Replace()?

This should work:

        var foo = "Some text,\r\n\r&#1​0;Another text .\r\n\r\nThird text";
        System.Console.WriteLine(foo); //Output: Some text,\r\n\r&#1​0;Another text .\r\n\r\nThird text
        System.Console.WriteLine(foo.Contains("&#1​0;")); //Output: True

        var bar = foo.Replace("&#1​0;", "<br/>");
        System.Console.WriteLine(bar); // Output: Output: Some text,\r\n\r<br/>Another text .\r\n\r\nThird text