Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

AntiXssEncoder.MarkAsSafe() doesnt recognize "–" and replace it with – hex value

$
0
0

Need help to pass right code charts to AntiXssEncoder.MarkAsSafe() so that below input would be persisted without replace that character with hex value. Hyphen  "–" seems to fall under Basic Latin code charts but after adding it to a safe list HtmlEncode() method encode it to &#8211.

sample code - (target framework - 4.5.1)

using System.Web.Security.AntiXss;

static void Main(string[] args)
        {
            AntiXssEncoder.MarkAsSafe(LowerCodeCharts.Default, LowerMidCodeCharts.LatinExtendedAdditional | LowerMidCodeCharts.CombiningDiacriticalMarksSupplement,
                MidCodeCharts.LatinExtendedC | MidCodeCharts.MiscellaneousMathematicalSymbolsA,
                UpperMidCodeCharts.CyrillicExtendedA,
                UpperCodeCharts.Specials);

            var value = AntiXssEncoder.HtmlEncode("Test –", false);
            Console.Write(value); // EXPECTED VALUE "Test –" AND NOT “Test &#8211"

        }




Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>