1 //------------------------------------------------------------------------------ 2 // <copyright file="Upper.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 //------------------------------------------------------------------------------ 6 7 namespace System.Web.Security.AntiXss.CodeCharts { 8 using System.Collections; 9 using System.Linq; 10 11 /// <summary> 12 /// Provides safe character positions for the upper section of the UTF code tables. 13 /// </summary> 14 internal static class Upper { 15 /// <summary> 16 /// Determines if the specified flag is set. 17 /// </summary> 18 /// <param name="flags">The value to check.</param> 19 /// <param name="flagToCheck">The flag to check for.</param> 20 /// <returns>true if the flag is set, otherwise false.</returns> IsFlagSet(UpperCodeCharts flags, UpperCodeCharts flagToCheck)21 public static bool IsFlagSet(UpperCodeCharts flags, UpperCodeCharts flagToCheck) { 22 return (flags & flagToCheck) != 0; 23 } 24 25 /// <summary> 26 /// Provides the safe characters for the Devanagari Extended code table. 27 /// </summary> 28 /// <returns>The safe characters for the code table.</returns> DevanagariExtended()29 public static IEnumerable DevanagariExtended() { 30 return CodeChartHelper.GetRange(0xA8E0, 0xA8FB); 31 } 32 33 /// <summary> 34 /// Provides the safe characters for the Kayah Li code table. 35 /// </summary> 36 /// <returns>The safe characters for the code table.</returns> KayahLi()37 public static IEnumerable KayahLi() { 38 return CodeChartHelper.GetRange(0xA900, 0xA92F); 39 } 40 41 /// <summary> 42 /// Provides the safe characters for the Rejang code table. 43 /// </summary> 44 /// <returns>The safe characters for the code table.</returns> Rejang()45 public static IEnumerable Rejang() { 46 return CodeChartHelper.GetRange(0xA930, 0xA953).Concat( 47 new[] { 0xA95F }); 48 } 49 50 /// <summary> 51 /// Provides the safe characters for the Hangul Jamo Extended A code table. 52 /// </summary> 53 /// <returns>The safe characters for the code table.</returns> HangulJamoExtendedA()54 public static IEnumerable HangulJamoExtendedA() { 55 return CodeChartHelper.GetRange(0xA960, 0xA97C); 56 } 57 58 /// <summary> 59 /// Provides the safe characters for the Javanese code table. 60 /// </summary> 61 /// <returns>The safe characters for the code table.</returns> Javanese()62 public static IEnumerable Javanese() { 63 return CodeChartHelper.GetRange(0xA980, 0xA9DF, 64 i => (i == 0xA9CE || 65 (i >= 0xA9DA && i <= 0xA9DD))); 66 } 67 68 /// <summary> 69 /// Provides the safe characters for the Cham code table. 70 /// </summary> 71 /// <returns>The safe characters for the code table.</returns> Cham()72 public static IEnumerable Cham() { 73 return CodeChartHelper.GetRange(0xAA00, 0xAA5F, 74 i => ((i >= 0xAA37 && i <= 0xAA3F) || 75 i == 0xAA4E || 76 i == 0xAA4F || 77 i == 0xAA5A || 78 i == 0xAA5B)); 79 } 80 81 /// <summary> 82 /// Provides the safe characters for the Myanmar Extended A code table. 83 /// </summary> 84 /// <returns>The safe characters for the code table.</returns> MyanmarExtendedA()85 public static IEnumerable MyanmarExtendedA() { 86 return CodeChartHelper.GetRange(0xAA60, 0xAA7B); 87 } 88 89 /// <summary> 90 /// Provides the safe characters for the Myanmar Extended A code table. 91 /// </summary> 92 /// <returns>The safe characters for the code table.</returns> TaiViet()93 public static IEnumerable TaiViet() { 94 return CodeChartHelper.GetRange(0xAA80, 0xAAC2).Concat( 95 CodeChartHelper.GetRange(0xAADB, 0xAADF)); 96 } 97 98 /// <summary> 99 /// Provides the safe characters for the Meetei Mayek code table. 100 /// </summary> 101 /// <returns>The safe characters for the code table.</returns> MeeteiMayek()102 public static IEnumerable MeeteiMayek() { 103 return CodeChartHelper.GetRange(0xABC0, 0xABF9, 104 i => (i == 0xABEE || 105 i == 0xABEF)); 106 } 107 108 /// <summary> 109 /// Provides the safe characters for the Hangul Syllables code table. 110 /// </summary> 111 /// <returns>The safe characters for the code table.</returns> HangulSyllables()112 public static IEnumerable HangulSyllables() { 113 return CodeChartHelper.GetRange(0xAC00, 0xD7A3); 114 } 115 116 /// <summary> 117 /// Provides the safe characters for the Hangul Jamo Extended B code table. 118 /// </summary> 119 /// <returns>The safe characters for the code table.</returns> HangulJamoExtendedB()120 public static IEnumerable HangulJamoExtendedB() { 121 return CodeChartHelper.GetRange(0xD7B0, 0xD7FB, 122 i => (i == 0xD7C7 || 123 i == 0xD7C8 || 124 i == 0xD7C9 || 125 i == 0xD7CA)); 126 } 127 128 /// <summary> 129 /// Provides the safe characters for the CJK Compatibility Ideographs code table. 130 /// </summary> 131 /// <returns>The safe characters for the code table.</returns> CjkCompatibilityIdeographs()132 public static IEnumerable CjkCompatibilityIdeographs() { 133 return CodeChartHelper.GetRange(0xF900, 0xFAD9, 134 i => (i == 0xFA2E || 135 i == 0xFA2F || 136 i == 0xFA6E || 137 i == 0xFA6F)); 138 } 139 140 /// <summary> 141 /// Provides the safe characters for the Alphabetic Presentation Forms code table. 142 /// </summary> 143 /// <returns>The safe characters for the code table.</returns> AlphabeticPresentationForms()144 public static IEnumerable AlphabeticPresentationForms() { 145 return CodeChartHelper.GetRange(0xFB00, 0xFB4F, 146 i => ((i >= 0xFB07 && i <= 0xFB12) || 147 (i >= 0xFB18 && i <= 0xFB1C) || 148 i == 0xFB37 || 149 i == 0xFB3D || 150 i == 0xFB3F || 151 i == 0xFB42 || 152 i == 0xFB45)); 153 } 154 155 /// <summary> 156 /// Provides the safe characters for the Arabic Presentation Forms A code table. 157 /// </summary> 158 /// <returns>The safe characters for the code table.</returns> ArabicPresentationFormsA()159 public static IEnumerable ArabicPresentationFormsA() { 160 return CodeChartHelper.GetRange(0xFB50, 0xFDFD, 161 i => ((i >= 0xFBB2 && i <= 0xFBD2) || 162 (i >= 0xFD40 && i <= 0xFD4F) || 163 i == 0xFD90 || 164 i == 0xFD91 || 165 (i >= 0xFDC8 && i <= 0xFDEF))); 166 } 167 168 /// <summary> 169 /// Provides the safe characters for the Variation Selectors code table. 170 /// </summary> 171 /// <returns>The safe characters for the code table.</returns> VariationSelectors()172 public static IEnumerable VariationSelectors() { 173 return CodeChartHelper.GetRange(0xFE00, 0xFE0F); 174 } 175 176 /// <summary> 177 /// Provides the safe characters for the Vertical Forms code table. 178 /// </summary> 179 /// <returns>The safe characters for the code table.</returns> VerticalForms()180 public static IEnumerable VerticalForms() { 181 return CodeChartHelper.GetRange(0xFE10, 0xFE19); 182 } 183 184 /// <summary> 185 /// Provides the safe characters for the Combining Half Marks code table. 186 /// </summary> 187 /// <returns>The safe characters for the code table.</returns> CombiningHalfMarks()188 public static IEnumerable CombiningHalfMarks() { 189 return CodeChartHelper.GetRange(0xFE20, 0xFE26); 190 } 191 192 /// <summary> 193 /// Provides the safe characters for the CJK Compatibility Forms code table. 194 /// </summary> 195 /// <returns>The safe characters for the code table.</returns> CjkCompatibilityForms()196 public static IEnumerable CjkCompatibilityForms() { 197 return CodeChartHelper.GetRange(0xFE30, 0xFE4F); 198 } 199 200 /// <summary> 201 /// Provides the safe characters for the Small Form Variants code table. 202 /// </summary> 203 /// <returns>The safe characters for the code table.</returns> SmallFormVariants()204 public static IEnumerable SmallFormVariants() { 205 return CodeChartHelper.GetRange(0xFE50, 0xFE6B, 206 i => (i == 0xFE53 || i == 0xFE67)); 207 } 208 209 /// <summary> 210 /// Provides the safe characters for the Arabic Presentation Forms B code table. 211 /// </summary> 212 /// <returns>The safe characters for the code table.</returns> ArabicPresentationFormsB()213 public static IEnumerable ArabicPresentationFormsB() { 214 return CodeChartHelper.GetRange(0xFE70, 0xFEFC, 215 i => (i == 0xFE75)); 216 } 217 218 /// <summary> 219 /// Provides the safe characters for the Half Width and Full Width Forms code table. 220 /// </summary> 221 /// <returns>The safe characters for the code table.</returns> HalfWidthAndFullWidthForms()222 public static IEnumerable HalfWidthAndFullWidthForms() { 223 return CodeChartHelper.GetRange(0xFF01, 0xFFEE, 224 i => (i == 0xFFBF || 225 i == 0xFFC0 || 226 i == 0xFFC1 || 227 i == 0xFFC8 || 228 i == 0xFFC9 || 229 i == 0xFFD0 || 230 i == 0xFFD1 || 231 i == 0xFFD8 || 232 i == 0xFFD9 || 233 i == 0xFFDD || 234 i == 0xFFDE || 235 i == 0xFFDF || 236 i == 0xFFE7)); 237 } 238 239 /// <summary> 240 /// Provides the safe characters for the Specials code table. 241 /// </summary> 242 /// <returns>The safe characters for the code table.</returns> Specials()243 public static IEnumerable Specials() { 244 return CodeChartHelper.GetRange(0xFFF9, 0xFFFD); 245 } 246 } 247 } 248