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 ParseSkipToNextDelimiterByte(byte delimiter) { MimeStringList mimeStringList = default(MimeStringList); for (;;) { if (this.position != this.end) { byte b = this.bytes[this.position]; if (b == delimiter) { break; } if (b == 34) { this.ParseQString(false, ref mimeStringList, true); } else if (b == 40) { this.ParseComment(false, false, ref mimeStringList, true); } else { this.position++; this.ParseCFWS(false, ref mimeStringList, true); int num = 0; this.position += MimeScan.FindEndOf(MimeScan.Token.Atom, this.bytes, this.position, this.end - this.position, out num, this.allowUTF8); } } else if (!this.ParseNextLine()) { return; } } }
// Token: 0x0600019F RID: 415 RVA: 0x00007578 File Offset: 0x00005778 private bool IsQuotingRequired(MimeString mimeStr, bool allowUTF8) { AddressItem.WriteState writeState = AddressItem.WriteState.Begin; MimeString mimeString = new MimeString(AddressItem.WordBreakBytes, 0, AddressItem.WordBreakBytes.Length); int num; int num2; byte[] data = mimeStr.GetData(out num, out num2); while (num2 != 0) { switch (writeState) { case AddressItem.WriteState.Begin: { int num3 = 0; int num4 = MimeScan.FindEndOf(MimeScan.Token.Atom, data, num, num2, out num3, allowUTF8); if (num4 == 0) { if (num2 <= 3 || num != 0 || !mimeString.HasPrefixEq(data, 0, 3)) { return(true); } num += 3; num2 -= 3; writeState = AddressItem.WriteState.Begin; } else { num += num4; num2 -= num4; writeState = AddressItem.WriteState.Atom; } break; } case AddressItem.WriteState.Atom: if ((num2 < 2 || data[num] != 32) && (num2 < 1 || data[num] != 46)) { return(true); } num++; num2--; writeState = AddressItem.WriteState.Begin; break; } } return(false); }
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); }
// Token: 0x0600046A RID: 1130 RVA: 0x00019454 File Offset: 0x00017654 public static int SkipLwsp(byte[] bytes, int offset, int length) { int num = 0; return(MimeScan.FindEndOf(MimeScan.Token.Lwsp, bytes, offset, length, out num, false)); }
public static int ParseToken(MimeString str, out int characterCount, bool allowUTF8) { return(MimeScan.FindEndOf(MimeScan.Token.Token, str.Data, str.Offset, str.Length, out characterCount, allowUTF8)); }
public static int ParseToken(string value, int currentOffset, bool allowUTF8) { return(MimeScan.FindEndOf(MimeScan.Token.Token, value, currentOffset, allowUTF8)); }
// Token: 0x06000324 RID: 804 RVA: 0x0001178C File Offset: 0x0000F98C public MimeToken Parse(byte[] data, int start, int end, bool flush) { int num = start + this.currentOffset; int num2 = start + this.lineOffset; switch (this.state) { case MimeParser.ParseState.Headers: { bool flag = false; int num3 = ByteString.IndexOf(data, 10, num, end - num); if (num3 == -1) { num3 = end; } if (num3 == end) { if ((end - start <= 998 && !flush) || (!flush && end - start <= 999 && data[end - 1] == 13)) { this.currentOffset = end - start; return(new MimeToken(MimeTokenId.None, 0)); } } else if (num3 == start || data[num3 - 1] != 13) { this.compliance |= MimeComplianceStatus.BareLinefeedInHeader; flag = true; } else { num3--; } this.headerNameLength = 0; this.headerDataOffset = 0; int num4; if (num3 - start > 998) { this.compliance |= MimeComplianceStatus.InvalidWrapping; this.currentOffset = num3 - (start + 998); this.lineOffset = num2 - (start + 998); num3 = start + 998; num4 = 0; } else { this.currentOffset = 0; this.lineOffset = ((num3 == end) ? (num2 - num3) : 0); num4 = ((num3 == end) ? 0 : (flag ? 1 : 2)); } if (num3 == start) { this.state = MimeParser.ParseState.EndOfHeaders; this.lastTokenLength = num4; return(new MimeToken(MimeTokenId.EndOfHeaders, this.lastTokenLength)); } if (num4 != 0 && num3 + num4 < end && data[num3 + num4] != 32 && data[num3 + num4] != 9) { this.headerComplete = true; } else { this.headerComplete = false; } if (!this.firstHeader && (num2 < start || data[num2] == 32 || data[num2] == 9)) { this.lastTokenLength = num3 + num4 - start; return(new MimeToken(MimeTokenId.HeaderContinuation, this.lastTokenLength)); } this.firstHeader = false; int num5 = 0; this.headerNameLength = MimeScan.FindEndOf(MimeScan.Token.Field, data, start, num3 - start, out num5, false); if (this.headerNameLength == 0) { this.compliance |= MimeComplianceStatus.InvalidHeader; this.lastTokenLength = num3 + num4 - start; return(new MimeToken(MimeTokenId.Header, this.lastTokenLength)); } int num6 = start + this.headerNameLength; if (num6 == num3 || data[num6] != 58) { num6 += MimeScan.SkipLwsp(data, num6, num3 - num6); if (num6 == num3 || data[num6] != 58) { this.headerNameLength = 0; if (this.mime && (this.parseStackTop > 0 || this.currentLevel.ContentType == MajorContentType.Multipart) && num3 - num2 > 2 && data[num2] == 45 && data[num2 + 1] == 45 && this.FindBoundary(data, num2, num3, out this.nextBoundaryLevel, out this.nextBoundaryEnd)) { this.compliance |= MimeComplianceStatus.MissingBodySeparator; if (this.nextBoundaryLevel != this.parseStackTop) { this.compliance |= MimeComplianceStatus.MissingBoundary; } this.lineOffset = 0; this.currentOffset = num3 - start; this.state = MimeParser.ParseState.EndOfHeaders; return(new MimeToken(MimeTokenId.EndOfHeaders, 0)); } this.compliance |= MimeComplianceStatus.InvalidHeader; this.lastTokenLength = num3 + num4 - start; return(new MimeToken(MimeTokenId.Header, this.lastTokenLength)); } } this.headerDataOffset = num6 + 1 - start; this.lastTokenLength = num3 + num4 - start; return(new MimeToken(MimeTokenId.Header, this.lastTokenLength)); } case MimeParser.ParseState.EndOfHeaders: this.CheckMimeConstraints(); if (this.mime && this.parseEmbeddedMessages && this.currentLevel.ContentType == MajorContentType.MessageRfc822 && !this.currentLevel.StreamMode) { this.PushLevel(false); this.lastTokenLength = 0; return(new MimeToken(MimeTokenId.EmbeddedStart, 0)); } this.state = MimeParser.ParseState.Body; break; case MimeParser.ParseState.Body: break; default: return(new MimeToken(MimeTokenId.EndOfFile, 0)); } return(this.ParseBody(data, start, end, flush, num2, num)); }