//------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //------------------------------------------------------------------------------ namespace System.Web.Security.AntiXss.CodeCharts { using System.Collections; using System.Linq; /// /// Provides safe character positions for the upper section of the UTF code tables. /// internal static class Upper { /// /// Determines if the specified flag is set. /// /// The value to check. /// The flag to check for. /// true if the flag is set, otherwise false. public static bool IsFlagSet(UpperCodeCharts flags, UpperCodeCharts flagToCheck) { return (flags & flagToCheck) != 0; } /// /// Provides the safe characters for the Devanagari Extended code table. /// /// The safe characters for the code table. public static IEnumerable DevanagariExtended() { return CodeChartHelper.GetRange(0xA8E0, 0xA8FB); } /// /// Provides the safe characters for the Kayah Li code table. /// /// The safe characters for the code table. public static IEnumerable KayahLi() { return CodeChartHelper.GetRange(0xA900, 0xA92F); } /// /// Provides the safe characters for the Rejang code table. /// /// The safe characters for the code table. public static IEnumerable Rejang() { return CodeChartHelper.GetRange(0xA930, 0xA953).Concat( new[] { 0xA95F }); } /// /// Provides the safe characters for the Hangul Jamo Extended A code table. /// /// The safe characters for the code table. public static IEnumerable HangulJamoExtendedA() { return CodeChartHelper.GetRange(0xA960, 0xA97C); } /// /// Provides the safe characters for the Javanese code table. /// /// The safe characters for the code table. public static IEnumerable Javanese() { return CodeChartHelper.GetRange(0xA980, 0xA9DF, i => (i == 0xA9CE || (i >= 0xA9DA && i <= 0xA9DD))); } /// /// Provides the safe characters for the Cham code table. /// /// The safe characters for the code table. public static IEnumerable Cham() { return CodeChartHelper.GetRange(0xAA00, 0xAA5F, i => ((i >= 0xAA37 && i <= 0xAA3F) || i == 0xAA4E || i == 0xAA4F || i == 0xAA5A || i == 0xAA5B)); } /// /// Provides the safe characters for the Myanmar Extended A code table. /// /// The safe characters for the code table. public static IEnumerable MyanmarExtendedA() { return CodeChartHelper.GetRange(0xAA60, 0xAA7B); } /// /// Provides the safe characters for the Myanmar Extended A code table. /// /// The safe characters for the code table. public static IEnumerable TaiViet() { return CodeChartHelper.GetRange(0xAA80, 0xAAC2).Concat( CodeChartHelper.GetRange(0xAADB, 0xAADF)); } /// /// Provides the safe characters for the Meetei Mayek code table. /// /// The safe characters for the code table. public static IEnumerable MeeteiMayek() { return CodeChartHelper.GetRange(0xABC0, 0xABF9, i => (i == 0xABEE || i == 0xABEF)); } /// /// Provides the safe characters for the Hangul Syllables code table. /// /// The safe characters for the code table. public static IEnumerable HangulSyllables() { return CodeChartHelper.GetRange(0xAC00, 0xD7A3); } /// /// Provides the safe characters for the Hangul Jamo Extended B code table. /// /// The safe characters for the code table. public static IEnumerable HangulJamoExtendedB() { return CodeChartHelper.GetRange(0xD7B0, 0xD7FB, i => (i == 0xD7C7 || i == 0xD7C8 || i == 0xD7C9 || i == 0xD7CA)); } /// /// Provides the safe characters for the CJK Compatibility Ideographs code table. /// /// The safe characters for the code table. public static IEnumerable CjkCompatibilityIdeographs() { return CodeChartHelper.GetRange(0xF900, 0xFAD9, i => (i == 0xFA2E || i == 0xFA2F || i == 0xFA6E || i == 0xFA6F)); } /// /// Provides the safe characters for the Alphabetic Presentation Forms code table. /// /// The safe characters for the code table. public static IEnumerable AlphabeticPresentationForms() { return CodeChartHelper.GetRange(0xFB00, 0xFB4F, i => ((i >= 0xFB07 && i <= 0xFB12) || (i >= 0xFB18 && i <= 0xFB1C) || i == 0xFB37 || i == 0xFB3D || i == 0xFB3F || i == 0xFB42 || i == 0xFB45)); } /// /// Provides the safe characters for the Arabic Presentation Forms A code table. /// /// The safe characters for the code table. public static IEnumerable ArabicPresentationFormsA() { return CodeChartHelper.GetRange(0xFB50, 0xFDFD, i => ((i >= 0xFBB2 && i <= 0xFBD2) || (i >= 0xFD40 && i <= 0xFD4F) || i == 0xFD90 || i == 0xFD91 || (i >= 0xFDC8 && i <= 0xFDEF))); } /// /// Provides the safe characters for the Variation Selectors code table. /// /// The safe characters for the code table. public static IEnumerable VariationSelectors() { return CodeChartHelper.GetRange(0xFE00, 0xFE0F); } /// /// Provides the safe characters for the Vertical Forms code table. /// /// The safe characters for the code table. public static IEnumerable VerticalForms() { return CodeChartHelper.GetRange(0xFE10, 0xFE19); } /// /// Provides the safe characters for the Combining Half Marks code table. /// /// The safe characters for the code table. public static IEnumerable CombiningHalfMarks() { return CodeChartHelper.GetRange(0xFE20, 0xFE26); } /// /// Provides the safe characters for the CJK Compatibility Forms code table. /// /// The safe characters for the code table. public static IEnumerable CjkCompatibilityForms() { return CodeChartHelper.GetRange(0xFE30, 0xFE4F); } /// /// Provides the safe characters for the Small Form Variants code table. /// /// The safe characters for the code table. public static IEnumerable SmallFormVariants() { return CodeChartHelper.GetRange(0xFE50, 0xFE6B, i => (i == 0xFE53 || i == 0xFE67)); } /// /// Provides the safe characters for the Arabic Presentation Forms B code table. /// /// The safe characters for the code table. public static IEnumerable ArabicPresentationFormsB() { return CodeChartHelper.GetRange(0xFE70, 0xFEFC, i => (i == 0xFE75)); } /// /// Provides the safe characters for the Half Width and Full Width Forms code table. /// /// The safe characters for the code table. public static IEnumerable HalfWidthAndFullWidthForms() { return CodeChartHelper.GetRange(0xFF01, 0xFFEE, i => (i == 0xFFBF || i == 0xFFC0 || i == 0xFFC1 || i == 0xFFC8 || i == 0xFFC9 || i == 0xFFD0 || i == 0xFFD1 || i == 0xFFD8 || i == 0xFFD9 || i == 0xFFDD || i == 0xFFDE || i == 0xFFDF || i == 0xFFE7)); } /// /// Provides the safe characters for the Specials code table. /// /// The safe characters for the code table. public static IEnumerable Specials() { return CodeChartHelper.GetRange(0xFFF9, 0xFFFD); } } }