public void ParseParameterValue(ref MimeStringList value, ref bool goodValue, bool handleISO2022) { MimeStringList mimeStringList = default(MimeStringList); goodValue = true; while (this.position != this.end || this.ParseNextLine()) { byte b = this.bytes[this.position]; if (b == 34) { value.Reset(); mimeStringList.Reset(); this.ParseQString(true, ref value, handleISO2022); return; } if (b == 40 || MimeScan.IsLWSP(b)) { this.ParseCFWS(true, ref mimeStringList, handleISO2022); } else { if (b == 59) { return; } int num = this.position; do { int num2 = 1; if (!MimeScan.IsToken(b)) { if (this.allowUTF8 && b >= 128) { if (!MimeScan.IsUTF8NonASCII(this.bytes, this.position, this.end, out num2)) { num2 = 1; goodValue = false; } } else { goodValue = false; } } this.position += num2; if (this.position == this.end) { break; } b = this.bytes[this.position]; }while (b != 59 && b != 40 && !MimeScan.IsLWSP(b)); value.TakeOverAppend(ref mimeStringList); value.AppendFragment(new MimeString(this.bytes, num, this.position - num)); } } }
private static void ParseValue(MimeStringList list, out DateTime utcDateTime, out TimeSpan timeZoneOffset) { MimeStringList mimeStringList = default(MimeStringList); ValueParser valueParser = new ValueParser(list, false); DateHeader.ParseStage parseStage = DateHeader.ParseStage.DayOfWeek; int[] array = new int[8]; byte b = 32; while (parseStage != DateHeader.ParseStage.Count) { valueParser.ParseCFWS(false, ref mimeStringList, true); byte b2 = valueParser.ParseGet(); if (b2 == 0) { break; } if (!MimeScan.IsToken(b2) || b2 == 45 || b2 == 43) { b = b2; valueParser.ParseCFWS(false, ref mimeStringList, true); } else { if (MimeScan.IsDigit(b2)) { if (parseStage == DateHeader.ParseStage.DayOfWeek) { parseStage = DateHeader.ParseStage.DayOfMonth; } if (parseStage == DateHeader.ParseStage.Second && b != 58) { parseStage = DateHeader.ParseStage.Zone; } int num = 0; do { num++; array[(int)parseStage] *= 10; array[(int)parseStage] += (int)(b2 - 48); b2 = valueParser.ParseGet(); }while (b2 != 0 && MimeScan.IsDigit(b2)); if (b2 != 0) { valueParser.ParseUnget(); } if (parseStage == DateHeader.ParseStage.Year && num <= 2) { array[(int)parseStage] += ((array[(int)parseStage] < 30) ? 2000 : 1900); } if (parseStage == DateHeader.ParseStage.Zone && num <= 2) { array[(int)parseStage] *= 100; } if (parseStage == DateHeader.ParseStage.Zone && b == 45) { array[(int)parseStage] = -array[(int)parseStage]; } parseStage++; } else if (MimeScan.IsAlpha(b2)) { valueParser.ParseUnget(); MimeString mimeString = valueParser.ParseToken(MimeScan.Token.Alpha); if (parseStage == DateHeader.ParseStage.DayOfWeek) { parseStage = DateHeader.ParseStage.DayOfMonth; } else if (parseStage == DateHeader.ParseStage.Month) { array[(int)parseStage] = DateHeader.MapMonthToInt(mimeString.Data, mimeString.Offset, mimeString.Length); parseStage = DateHeader.ParseStage.Year; } else if (parseStage >= DateHeader.ParseStage.Second) { if (mimeString.Length == 2 && 65 == DateHeader.MakeUpper(mimeString[0]) && 77 == DateHeader.MakeUpper(mimeString[1])) { if (array[4] == 12) { array[4] = 0; } parseStage = DateHeader.ParseStage.Zone; } else if (mimeString.Length == 2 && 80 == DateHeader.MakeUpper(mimeString[0]) && 77 == DateHeader.MakeUpper(mimeString[1])) { if (array[4] < 12) { array[4] += 12; } parseStage = DateHeader.ParseStage.Zone; } else { array[7] = (int)DateHeader.MapZoneToInt(mimeString.Data, mimeString.Offset, mimeString.Length); parseStage = DateHeader.ParseStage.Count; } } } b = 32; } } if (parseStage > DateHeader.ParseStage.Year) { int num2 = array[3]; int num3 = array[2]; int num4 = array[1]; int num5 = array[4]; int num6 = array[5]; int num7 = array[6]; if (num5 == 23 && num6 == 59 && num7 == 60) { num7 = 59; } if (num2 >= 1900 && num2 <= 9999 && num3 >= 1 && num3 <= 12 && num4 >= 1 && num4 <= DateTime.DaysInMonth(num2, num3) && num5 >= 0 && num5 < 24 && num6 >= 0 && num6 < 60 && num7 >= 0 && num7 < 60) { try { utcDateTime = new DateTime(num2, num3, num4, num5, num6, num7, 0, DateTimeKind.Utc); goto IL_319; } catch (ArgumentException) { utcDateTime = DateHeader.minDateTime; goto IL_319; } } utcDateTime = DateHeader.minDateTime; } else { utcDateTime = DateHeader.minDateTime; } IL_319: if (parseStage != DateHeader.ParseStage.Count || !(utcDateTime > DateHeader.minDateTime)) { timeZoneOffset = TimeSpan.Zero; return; } int num8 = array[7] / 100; int num9 = array[7] % 100; if (num8 > 99 || num8 < -99) { num8 = 0; num9 = 0; } if (num9 > 59 || num9 < -59) { num9 = 0; } timeZoneOffset = new TimeSpan(num8, num9, 0); if (utcDateTime.Ticks >= timeZoneOffset.Ticks && DateTime.MaxValue.Ticks >= utcDateTime.Ticks - timeZoneOffset.Ticks) { utcDateTime -= timeZoneOffset; return; } utcDateTime = DateHeader.minDateTime; timeZoneOffset = TimeSpan.Zero; }