// Token: 0x06000544 RID: 1348 RVA: 0x0001CD90 File Offset: 0x0001AF90 internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { MimeStringList displayNameToWrite = base.GetDisplayNameToWrite(encodingOptions); long num = 0L; int num2 = 0; if (base.NextSibling != null) { num2++; } else if (base.Parent is MimeGroup) { num2++; if (base.Parent.NextSibling != null) { num2++; } } byte[] sz = this.emailAddressFragments.GetSz(); int num3 = ByteString.BytesToCharCount(sz, encodingOptions.AllowUTF8); if (displayNameToWrite.GetLength(4026531839U) != 0) { num += Header.QuoteAndFold(stream, displayNameToWrite, 4026531839U, base.IsQuotingRequired(displayNameToWrite, encodingOptions.AllowUTF8), true, encodingOptions.AllowUTF8, (num3 == 0) ? num2 : 0, ref currentLineLength, ref scratchBuffer); } if (num3 != 0) { int num4 = (1 < currentLineLength.InChars) ? 1 : 0; if (1 < currentLineLength.InChars) { if (currentLineLength.InChars + num3 + 2 + num2 + num4 > 78) { num += Header.WriteLineEnd(stream, ref currentLineLength); stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); } else { stream.Write(MimeString.Space, 0, MimeString.Space.Length); num += (long)MimeString.Space.Length; currentLineLength.IncrementBy(MimeString.Space.Length); } } stream.Write(MimeString.LessThan, 0, MimeString.LessThan.Length); num += (long)MimeString.LessThan.Length; currentLineLength.IncrementBy(MimeString.LessThan.Length); stream.Write(sz, 0, sz.Length); num += (long)sz.Length; currentLineLength.IncrementBy(num3, sz.Length); stream.Write(MimeString.GreaterThan, 0, MimeString.GreaterThan.Length); num += (long)MimeString.GreaterThan.Length; currentLineLength.IncrementBy(MimeString.GreaterThan.Length); } return(num); }
// Token: 0x0600024C RID: 588 RVA: 0x0000AD74 File Offset: 0x00008F74 internal static bool TryDecodeValue(MimeStringList lines, uint linesMask, DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value) { decodingResults = default(DecodingResults); if (lines.GetLength(linesMask) == 0) { value = string.Empty; return(true); } DecodingFlags decodingFlags = decodingOptions.DecodingFlags; bool flag = DecodingFlags.None != (DecodingFlags.FallbackToRaw & decodingFlags); bool allowControlCharacters = DecodingFlags.None != (DecodingFlags.AllowControlCharacters & decodingFlags); bool enable = false; bool enableJisDetection = false; bool enableUtf8Detection = false; bool enableDbcsDetection = false; Charset defaultCharset = null; ValueDecoder valueDecoder = new ValueDecoder(lines, linesMask); if ((decodingFlags & DecodingFlags.AllEncodings) == DecodingFlags.None) { if (!flag) { defaultCharset = Charset.ASCII; } } else { enable = (DecodingFlags.None != (DecodingFlags.Rfc2047 & decodingFlags)); enableJisDetection = (DecodingFlags.None != (DecodingFlags.Jis & decodingFlags)); enableUtf8Detection = (DecodingFlags.None != (DecodingFlags.Utf8 & decodingFlags)); enableDbcsDetection = (DecodingFlags.None != (DecodingFlags.Dbcs & decodingFlags)); defaultCharset = decodingOptions.Charset; } string charsetName; string cultureName; EncodingScheme encodingScheme; bool flag2 = valueDecoder.TryDecodeValue(defaultCharset, flag, allowControlCharacters, enable, enableJisDetection, enableUtf8Detection, enableDbcsDetection, out charsetName, out cultureName, out encodingScheme, out value); decodingResults.EncodingScheme = encodingScheme; decodingResults.CharsetName = charsetName; decodingResults.CultureName = cultureName; decodingResults.DecodingFailed = !flag2; return(flag2); }
internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { MimeNode nextSibling = base.NextSibling; MimeStringList displayNameToWrite = base.GetDisplayNameToWrite(encodingOptions); long num = 0L; if (displayNameToWrite.GetLength(4026531839U) != 0) { int num2 = 1; if (base.FirstChild == null) { num2++; } if (base.NextSibling != null) { num2++; } num += Header.QuoteAndFold(stream, displayNameToWrite, 4026531839U, base.IsQuotingRequired(displayNameToWrite, encodingOptions.AllowUTF8), true, encodingOptions.AllowUTF8, num2, ref currentLineLength, ref scratchBuffer); stream.Write(MimeString.Colon, 0, MimeString.Colon.Length); num += (long)MimeString.Colon.Length; currentLineLength.IncrementBy(MimeString.Colon.Length); } MimeNode mimeNode = base.FirstChild; int num3 = 0; while (mimeNode != null) { if (1 < ++num3) { stream.Write(MimeString.Comma, 0, MimeString.Comma.Length); num += (long)MimeString.Comma.Length; currentLineLength.IncrementBy(MimeString.Comma.Length); } num += mimeNode.WriteTo(stream, encodingOptions, filter, ref currentLineLength, ref scratchBuffer); mimeNode = mimeNode.NextSibling; } stream.Write(MimeString.Semicolon, 0, MimeString.Semicolon.Length); num += (long)MimeString.Semicolon.Length; currentLineLength.IncrementBy(MimeString.Semicolon.Length); return(num); }
// Token: 0x060001A3 RID: 419 RVA: 0x00007708 File Offset: 0x00005908 internal MimeStringList GetDisplayNameToWrite(EncodingOptions encodingOptions) { MimeStringList result = this.displayNameFragments; if (result.GetLength(4026531839U) == 0 && this.decodedDisplayName != null && this.decodedDisplayName.Length != 0) { string value; if ((byte)(encodingOptions.EncodingFlags & EncodingFlags.QuoteDisplayNameBeforeRfc2047Encoding) != 0 && this.IsQuotingRequired(this.decodedDisplayName, encodingOptions.AllowUTF8) && MimeCommon.IsEncodingRequired(this.decodedDisplayName, encodingOptions.AllowUTF8)) { value = this.QuoteString(this.decodedDisplayName); } else { value = this.decodedDisplayName; } result = MimeCommon.EncodeValue(value, encodingOptions, ValueEncodingStyle.Phrase); this.displayNameFragments = result; } else if ((byte)(EncodingFlags.ForceReencode & encodingOptions.EncodingFlags) != 0) { result = MimeCommon.EncodeValue(this.DisplayName, encodingOptions, ValueEncodingStyle.Phrase); } return(result); }
// Token: 0x06000249 RID: 585 RVA: 0x0000A614 File Offset: 0x00008814 public AddressParserResult ParseNextMailbox(ref MimeStringList displayName, ref MimeStringList address) { AddressParserResult result = this.groupInProgress ? AddressParserResult.GroupInProgress : AddressParserResult.Mailbox; MimeAddressParser.ParserStage parserStage = MimeAddressParser.ParserStage.BEGIN; MimeStringList mimeStringList = default(MimeStringList); MimeStringList mimeStringList2 = default(MimeStringList); MimeStringList mimeStringList3 = default(MimeStringList); bool flag = true; bool flag2 = false; bool ignoreNextByte = false; if (!this.parserInit) { throw new InvalidOperationException(Strings.AddressParserNotInitialized); } for (;;) { if (this.valueParser.ParseToDelimiter(ignoreNextByte, !flag && flag2, ref mimeStringList)) { flag2 = false; ignoreNextByte = false; flag = false; } byte b = this.valueParser.ParseGet(); byte b2 = b; if (b2 <= 34) { if (b2 != 0) { switch (b2) { case 9: case 10: case 13: break; case 11: case 12: goto IL_200; default: switch (b2) { case 32: break; case 33: goto IL_200; case 34: this.valueParser.ParseUnget(); if (mimeStringList.Length != 0 && !flag) { this.valueParser.ParseAppendSpace(ref mimeStringList); } else { flag = false; } this.valueParser.ParseQString(true, ref mimeStringList, true); flag2 = true; continue; default: goto IL_200; } break; } this.valueParser.ParseWhitespace(false, ref mimeStringList3); flag2 = true; continue; } goto IL_213; } else if (b2 <= 46) { if (b2 == 40) { if (mimeStringList2.Length != 0) { mimeStringList2.Reset(); } this.valueParser.ParseUnget(); if (this.ignoreComments) { this.valueParser.ParseComment(true, false, ref mimeStringList2, true); if (flag2) { mimeStringList.AppendFragment(new MimeString(" ")); } mimeStringList.TakeOverAppend(ref mimeStringList2); } else { this.valueParser.ParseComment(true, true, ref mimeStringList2, true); } flag2 = true; continue; } switch (b2) { case 44: goto IL_213; case 46: this.valueParser.ParseAppendLastByte(ref mimeStringList); flag = true; continue; } } else { switch (b2) { case 58: case 59: case 60: case 62: case 64: goto IL_213; case 61: case 63: break; default: switch (b2) { case 91: case 93: goto IL_213; } break; } } IL_200: this.valueParser.ParseUnget(); ignoreNextByte = true; continue; IL_213: switch (parserStage) { case MimeAddressParser.ParserStage.BEGIN: { byte b3 = b; if (b3 > 44) { switch (b3) { case 58: if (mimeStringList.GetLength(4026531839U) != 0) { goto Block_26; } continue; case 59: this.groupInProgress = false; result = AddressParserResult.Mailbox; goto IL_28D; case 60: break; case 61: case 63: goto IL_33D; case 62: mimeStringList.Reset(); continue; case 64: { int length = mimeStringList.Length; this.valueParser.ParseAppendLastByte(ref mimeStringList); address.TakeOver(ref mimeStringList); parserStage = MimeAddressParser.ParserStage.ADDRSPEC; continue; } default: if (b3 != 91) { goto IL_33D; } if (!this.useSquareBrackets) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } break; } displayName.TakeOver(ref mimeStringList); parserStage = MimeAddressParser.ParserStage.ANGLEADDR; continue; } if (b3 == 0) { goto IL_330; } if (b3 != 44) { goto IL_33D; } IL_28D: if (mimeStringList.GetLength(4026531839U) != 0) { goto Block_25; } mimeStringList.Reset(); continue; IL_33D: this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } case MimeAddressParser.ParserStage.ANGLEADDR: { byte b4 = b; if (b4 <= 44) { if (b4 == 0) { goto IL_478; } if (b4 == 44) { if (displayName.Length != 0 || mimeStringList.Length != 0) { goto IL_478; } continue; } } else { switch (b4) { case 58: mimeStringList.Reset(); continue; case 59: case 61: case 63: goto IL_485; case 60: break; case 62: goto IL_432; case 64: if (mimeStringList.Length == 0) { parserStage = MimeAddressParser.ParserStage.ROUTEDOMAIN; continue; } this.valueParser.ParseAppendLastByte(ref mimeStringList); address.TakeOver(ref mimeStringList); parserStage = MimeAddressParser.ParserStage.ADDRSPEC; continue; default: switch (b4) { case 91: if (!this.useSquareBrackets) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } break; case 92: goto IL_485; case 93: if (!this.useSquareBrackets) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } goto IL_432; default: goto IL_485; } break; } if (mimeStringList.Length != 0) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } continue; IL_432: address.TakeOver(ref mimeStringList); if (address.Length != 0 || displayName.Length != 0) { parserStage = MimeAddressParser.ParserStage.END; continue; } parserStage = MimeAddressParser.ParserStage.BEGIN; continue; } IL_485: this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } case MimeAddressParser.ParserStage.ADDRSPEC: { byte b5 = b; if (b5 > 44) { switch (b5) { case 59: this.groupInProgress = false; goto IL_58B; case 60: if (displayName.Length == 0) { displayName.TakeOverAppend(ref address); parserStage = MimeAddressParser.ParserStage.ANGLEADDR; continue; } this.valueParser.ParseUnget(); ignoreNextByte = true; continue; case 61: goto IL_5B5; case 62: break; default: switch (b5) { case 91: if (mimeStringList.Length == 0) { this.valueParser.ParseUnget(); this.valueParser.ParseDomainLiteral(true, ref mimeStringList); address.TakeOverAppend(ref mimeStringList); parserStage = MimeAddressParser.ParserStage.END; continue; } this.valueParser.ParseUnget(); ignoreNextByte = true; continue; case 92: goto IL_5B5; case 93: if (!this.useSquareBrackets) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } break; default: goto IL_5B5; } break; } address.TakeOverAppend(ref mimeStringList); parserStage = MimeAddressParser.ParserStage.END; continue; } if (b5 != 0 && b5 != 44) { goto IL_5B5; } IL_58B: address.TakeOverAppend(ref mimeStringList); if (address.Length == 0 && displayName.Length == 0 && b != 0) { continue; } break; IL_5B5: this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } case MimeAddressParser.ParserStage.ROUTEDOMAIN: { byte b6 = b; if (b6 <= 44) { if (b6 == 0) { break; } if (b6 != 44) { goto IL_665; } } else if (b6 != 58) { if (b6 != 62) { switch (b6) { case 91: mimeStringList.Reset(); this.valueParser.ParseUnget(); this.valueParser.ParseDomainLiteral(false, ref mimeStringList3); continue; case 92: goto IL_665; case 93: if (!this.useSquareBrackets) { this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } break; default: goto IL_665; } } mimeStringList.Reset(); parserStage = MimeAddressParser.ParserStage.END; continue; } mimeStringList.Reset(); parserStage = MimeAddressParser.ParserStage.ANGLEADDR; continue; IL_665: this.valueParser.ParseUnget(); ignoreNextByte = true; continue; } case MimeAddressParser.ParserStage.END: { mimeStringList.Reset(); byte b7 = b; if (b7 != 0 && b7 != 44) { if (b7 != 59) { continue; } this.groupInProgress = false; } if (address.Length == 0 && displayName.Length == 0 && b != 0) { parserStage = MimeAddressParser.ParserStage.BEGIN; continue; } break; } } break; } goto IL_6B9; Block_25: displayName.TakeOver(ref mimeStringList); goto IL_6B9; Block_26: displayName.TakeOver(ref mimeStringList); this.groupInProgress = true; return(AddressParserResult.GroupStart); IL_330: displayName.TakeOver(ref mimeStringList); goto IL_6B9; IL_478: address.TakeOver(ref mimeStringList); IL_6B9: if (displayName.Length == 0 && mimeStringList2.Length != 0 && address.Length != 0) { displayName.TakeOver(ref mimeStringList2); } if (address.Length == 0 && displayName.Length == 0) { result = AddressParserResult.End; } return(result); }