private void ParseEscapedString(bool save, ref MimeStringList outStr, out bool singleByte) { bool flag = this.bytes[this.position] == 27; if (save) { outStr.AppendFragment(new MimeString(this.bytes, this.position, 1, 536870912U)); } this.position++; if (flag && !this.ParseEscapeSequence(save, ref outStr)) { singleByte = true; return; } singleByte = false; do { int num = MimeScan.ScanJISString(this.bytes, this.position, this.end - this.position, ref singleByte); if (save && num != 0) { outStr.AppendFragment(new MimeString(this.bytes, this.position, num, 536870912U)); } this.position += num; }while (!singleByte && this.ParseNextLine()); if (!flag && this.position != this.end && this.bytes[this.position] == 15) { if (save) { outStr.AppendFragment(new MimeString(this.bytes, this.position, 1, 536870912U)); } this.position++; } }
public void ParseAppendSpace(ref MimeStringList phrase) { if (this.position == this.start || this.bytes[this.position - 1] != 32) { phrase.AppendFragment(ValueParser.SpaceLine); return; } phrase.AppendFragment(new MimeString(this.bytes, this.position - 1, 1)); }
public void ParseQString(bool save, ref MimeStringList phrase, bool handleISO2022) { bool flag = false; if (save) { phrase.AppendFragment(new MimeString(this.bytes, this.position, 1, 268435456U)); } this.position++; bool flag2 = true; for (;;) { int num = MimeScan.ScanQuotedString(this.bytes, this.position, this.end - this.position, handleISO2022, ref flag); if (num != 0) { if (save) { phrase.AppendFragment(new MimeString(this.bytes, this.position, num)); } this.position += num; } if (this.position != this.end) { if (this.bytes[this.position] == 14 || this.bytes[this.position] == 27) { this.ParseEscapedString(save, ref phrase, out flag2); } else { if (save) { phrase.AppendFragment(new MimeString(this.bytes, this.position, 1, 268435456U)); } this.position++; if (this.bytes[this.position - 1] == 34) { break; } flag = true; } } else if (!this.ParseNextLine()) { goto Block_8; } } return; Block_8: if (save && flag2) { phrase.AppendFragment(new MimeString(MimeString.DoubleQuote, 0, MimeString.DoubleQuote.Length, 268435456U)); } }
public void ParseToEnd(ref MimeStringList phrase) { if (this.position != this.end) { phrase.AppendFragment(new MimeString(this.bytes, this.position, this.end - this.position)); this.position = this.end; } while (this.ParseNextLine()) { phrase.AppendFragment(new MimeString(this.bytes, this.start, this.end - this.start)); this.position = this.end; } }
public MimeString ParseToken(MimeScan.Token token) { MimeStringList mimeStringList = default(MimeStringList); while (this.position != this.end || this.ParseNextLine()) { int num = 0; int num2 = MimeScan.FindEndOf(token, this.bytes, this.position, this.end - this.position, out num, this.allowUTF8); if (num2 == 0) { break; } mimeStringList.AppendFragment(new MimeString(this.bytes, this.position, num2)); this.position += num2; } if (mimeStringList.Count == 0) { return(default(MimeString)); } if (mimeStringList.Count == 1) { return(mimeStringList[0]); } byte[] sz = mimeStringList.GetSz(); return(new MimeString(sz, 0, sz.Length)); }
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)); } } }
public void ParseDomainLiteral(bool save, ref MimeStringList domain) { bool flag = false; int num = this.position; this.position++; for (;;) { if (this.position == this.end) { if (num != this.position && save) { domain.AppendFragment(new MimeString(this.bytes, num, this.position - num)); } if (!this.ParseNextLine()) { break; } num = this.position; } byte b = this.bytes[this.position++]; if (flag) { flag = false; } else if (b == 92) { flag = true; } else if (b == 93) { goto IL_91; } } num = this.position; IL_91: if (num != this.position && save) { domain.AppendFragment(new MimeString(this.bytes, num, this.position - num)); } }
public void ParseComment(bool save, bool saveInnerOnly, ref MimeStringList comment, bool handleISO2022) { int num = 1; bool flag = false; int num2 = 0; if (save && !saveInnerOnly) { comment.AppendFragment(new MimeString(this.bytes, this.position, 1)); } this.position++; for (;;) { int num3 = MimeScan.ScanComment(this.bytes, this.position, this.end - this.position, handleISO2022, ref num, ref flag); if (num3 != 0) { if (save) { if (num == 0 && saveInnerOnly) { num2 = 1; } comment.AppendFragment(new MimeString(this.bytes, this.position, num3 - num2)); } this.position += num3; if (num == 0) { break; } } if (this.position != this.end && (this.bytes[this.position] == 14 || this.bytes[this.position] == 27)) { bool flag2; this.ParseEscapedString(save, ref comment, out flag2); } else if (!this.ParseNextLine()) { return; } } }
public bool ParseToDelimiter(bool ignoreNextByte, bool separateWithWhitespace, ref MimeStringList phrase) { bool result = false; int num = ignoreNextByte ? 1 : 0; for (;;) { int num2 = 0; num += MimeScan.FindEndOf(MimeScan.Token.Atom, this.bytes, this.position + num, this.end - this.position - num, out num2, this.allowUTF8); if (num != 0) { result = true; if (phrase.Length != 0 && separateWithWhitespace) { if (this.position == this.start || this.bytes[this.position - 1] != 32) { phrase.AppendFragment(ValueParser.SpaceLine); } else { this.position--; num++; } } separateWithWhitespace = false; phrase.AppendFragment(new MimeString(this.bytes, this.position, num)); this.position += num; } if (this.position != this.end || !this.ParseNextLine()) { break; } num = 0; } return(result); }
public void ParseWhitespace(bool save, ref MimeStringList phrase) { for (;;) { int num = MimeScan.SkipLwsp(this.bytes, this.position, this.end - this.position); if (save && num != 0) { phrase.AppendFragment(new MimeString(this.bytes, this.position, num)); } this.position += num; if (this.position != this.end) { break; } if (!this.ParseNextLine()) { return; } } }
public void ParseCFWS(bool save, ref MimeStringList phrase, bool handleISO2022) { for (;;) { int num = MimeScan.SkipLwsp(this.bytes, this.position, this.end - this.position); if (save && num != 0) { phrase.AppendFragment(new MimeString(this.bytes, this.position, num)); } this.position += num; if (this.position != this.end) { if (this.bytes[this.position] != 40) { break; } this.ParseComment(save, false, ref phrase, handleISO2022); } else if (!this.ParseNextLine()) { break; } } }
private void Parse() { this.Reset(); this.parsed = true; DecodingOptions headerDecodingOptions = base.GetHeaderDecodingOptions(); ValueParser valueParser = new ValueParser(base.Lines, headerDecodingOptions.AllowUTF8); MimeStringList mimeStringList = default(MimeStringList); MimeStringList mimeStringList2 = default(MimeStringList); MimeString mimeString = default(MimeString); MimeString mimeString2 = MimeString.Empty; ReceivedHeader.ParseState parseState = ReceivedHeader.ParseState.None; for (;;) { valueParser.ParseWhitespace(true, ref mimeStringList); byte b = valueParser.ParseGet(); if (b == 0) { break; } if (59 == b) { parseState = ReceivedHeader.ParseState.Date; } else if (40 == b && parseState == ReceivedHeader.ParseState.DomainValue) { parseState = ReceivedHeader.ParseState.DomainAddress; } else { valueParser.ParseUnget(); mimeString = valueParser.ParseToken(); if (mimeString.Length == 0) { valueParser.ParseGet(); mimeStringList2.TakeOverAppend(ref mimeStringList); valueParser.ParseAppendLastByte(ref mimeStringList2); continue; } ReceivedHeader.ParseState parseState2 = this.StateFromToken(mimeString); if (ReceivedHeader.ParseState.None != parseState2) { parseState = parseState2; } } switch (parseState) { case ReceivedHeader.ParseState.Domain: case ReceivedHeader.ParseState.OptInfo: if (mimeString2.Length != 0) { this.FinishClause(ref mimeString2, ref mimeStringList2, headerDecodingOptions.AllowUTF8); } else { mimeStringList2.Reset(); } mimeString2 = mimeString; valueParser.ParseWhitespace(false, ref mimeStringList); mimeStringList.Reset(); parseState++; break; case ReceivedHeader.ParseState.DomainValue: mimeStringList2.TakeOverAppend(ref mimeStringList); mimeStringList2.AppendFragment(mimeString); break; case ReceivedHeader.ParseState.DomainAddress: { bool flag = mimeString2.CompareEqI(ReceivedHeader.ParamFrom); this.FinishClause(ref mimeString2, ref mimeStringList2, headerDecodingOptions.AllowUTF8); mimeStringList.Reset(); valueParser.ParseUnget(); valueParser.ParseComment(true, false, ref mimeStringList2, true); byte[] sz = mimeStringList2.GetSz(); string text = (sz == null) ? null : ByteString.BytesToString(sz, headerDecodingOptions.AllowUTF8); if (flag) { this.fromTcpInfoValue = text; } else { this.byTcpInfoValue = text; } mimeStringList2.Reset(); parseState = ReceivedHeader.ParseState.None; break; } case ReceivedHeader.ParseState.OptInfoValue: mimeStringList2.TakeOverAppend(ref mimeStringList); mimeStringList2.AppendFragment(mimeString); break; case ReceivedHeader.ParseState.Date: { this.FinishClause(ref mimeString2, ref mimeStringList2, headerDecodingOptions.AllowUTF8); mimeStringList.Reset(); valueParser.ParseWhitespace(false, ref mimeStringList); valueParser.ParseToEnd(ref mimeStringList2); byte[] sz2 = mimeStringList2.GetSz(); this.dateValue = ((sz2 == null) ? null : ByteString.BytesToString(sz2, false)); break; } case ReceivedHeader.ParseState.None: mimeStringList2.Reset(); break; } } this.FinishClause(ref mimeString2, ref mimeStringList2, headerDecodingOptions.AllowUTF8); }
private bool ParseEscapeSequence(bool save, ref MimeStringList outStr) { byte b = this.ParseGet(); byte b2 = this.ParseGet(); byte b3 = this.ParseGet(); if (b3 != 0) { this.ParseUnget(); } if (b2 != 0) { this.ParseUnget(); } if (b != 0) { this.ParseUnget(); } int num = 0; bool result = false; byte b4 = b; if (b4 != 36) { if (b4 != 40) { switch (b4) { case 78: case 79: if (b2 >= 33) { num = 2; if (b3 >= 33) { num = 3; } } break; } } else if (b2 == 73) { result = true; num = 2; } else if (b2 == 66 || b2 == 74 || b2 == 72) { num = 2; } } else if (b2 == 66 || b2 == 65 || b2 == 64) { num = 2; result = true; } else if (b2 == 40 && (b3 == 67 || b3 == 68)) { num = 3; result = true; } while (num-- != 0) { this.ParseGet(); if (save) { outStr.AppendFragment(new MimeString(this.bytes, this.position - 1, 1, 536870912U)); } } return(result); }
public void ParseAppendLastByte(ref MimeStringList phrase) { phrase.AppendFragment(new MimeString(this.bytes, this.position - 1, 1)); }
// 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); }