internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = base.WriteName(stream, ref scratchBuffer); currentLineLength.IncrementBy((int)num); if (!base.IsDirty && base.RawLength != 0 && base.IsProtected) { long num2 = Header.WriteLines(base.Lines, stream); num += num2; currentLineLength.SetAs(0); return(num); } if (!this.parsed) { this.Parse(); } num += this.WriteValue(stream, encodingOptions, filter, ref currentLineLength, ref scratchBuffer); for (MimeNode mimeNode = base.FirstChild; mimeNode != null; mimeNode = mimeNode.NextSibling) { stream.Write(MimeString.Semicolon, 0, MimeString.Semicolon.Length); num += (long)MimeString.Semicolon.Length; currentLineLength.IncrementBy(MimeString.Semicolon.Length); num += mimeNode.WriteTo(stream, encodingOptions, filter, ref currentLineLength, ref scratchBuffer); } return(num + Header.WriteLineEnd(stream, ref currentLineLength)); }
// 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); }
internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = this.WriteName(stream, ref scratchBuffer); currentLineLength.IncrementBy((int)num); bool flag = false; if (!this.IsDirty && this.RawLength != 0) { if (this.IsProtected) { num += Header.WriteLines(this.lines, stream); currentLineLength.SetAs(0); return(num); } if (!this.IsHeaderLineTooLong(num, out flag)) { num += Header.WriteLines(this.lines, stream); currentLineLength.SetAs(0); return(num); } } MimeStringList fragments = this.lines; if (flag) { fragments = Header.MergeLines(fragments); } num += Header.QuoteAndFold(stream, fragments, 4026531840U, false, fragments.Length > 0, encodingOptions.AllowUTF8, 0, ref currentLineLength, ref scratchBuffer); return(num + Header.WriteLineEnd(stream, ref currentLineLength)); }
// Token: 0x0600018B RID: 395 RVA: 0x00007074 File Offset: 0x00005274 internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = base.WriteName(stream, ref scratchBuffer); currentLineLength.IncrementBy((int)num); if (!base.IsDirty && base.RawLength != 0) { if (base.IsProtected) { num += Header.WriteLines(base.Lines, stream); currentLineLength.SetAs(0); return(num); } if (base.InternalLastChild == null) { bool flag = false; if (!base.IsHeaderLineTooLong(num, out flag)) { num += Header.WriteLines(base.Lines, stream); currentLineLength.SetAs(0); return(num); } } } if (!this.parsed) { this.Parse(); } MimeNode mimeNode = base.FirstChild; int num2 = 0; while (mimeNode != null) { if (1 < ++num2) { 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; } return(num + Header.WriteLineEnd(stream, ref currentLineLength)); }
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); }
internal static long WriteDateHeaderValue(Stream stream, DateTime utcDateTime, TimeSpan timeZoneOffset, ref MimeStringLength currentLineLength) { long num = 0L; int countInChars = 0; byte[] array = DateHeader.FormatValue(utcDateTime, timeZoneOffset, out countInChars); stream.Write(MimeString.Space, 0, MimeString.Space.Length); num += (long)MimeString.Space.Length; currentLineLength.IncrementBy(MimeString.Space.Length); if (array != null) { stream.Write(array, 0, array.Length); num += (long)array.Length; currentLineLength.IncrementBy(countInChars, array.Length); } else { stream.Write(MimeString.CommentInvalidDate, 0, MimeString.CommentInvalidDate.Length); num += (long)MimeString.CommentInvalidDate.Length; currentLineLength.IncrementBy(MimeString.CommentInvalidDate.Length); } return(num + Header.WriteLineEnd(stream, ref currentLineLength)); }
// Token: 0x06000554 RID: 1364 RVA: 0x0001D1D4 File Offset: 0x0001B3D4 internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = base.WriteName(stream, ref scratchBuffer); currentLineLength.IncrementBy((int)num); MimeStringList mimeStringList; if (base.RawLength == 0 && this.decodedValue != null && this.decodedValue.Length != 0) { mimeStringList = this.GetEncodedValue(encodingOptions, ValueEncodingStyle.Normal); } else if ((byte)(EncodingFlags.ForceReencode & encodingOptions.EncodingFlags) != 0) { this.ForceParse(); mimeStringList = this.GetEncodedValue(encodingOptions, ValueEncodingStyle.Normal); } else { bool flag = false; if (!base.IsDirty && base.RawLength != 0) { if (base.IsProtected) { num += Header.WriteLines(base.Lines, stream); currentLineLength.SetAs(0); return(num); } if (!base.IsHeaderLineTooLong(num, out flag)) { num += Header.WriteLines(base.Lines, stream); currentLineLength.SetAs(0); return(num); } } mimeStringList = base.Lines; if (flag) { mimeStringList = Header.MergeLines(mimeStringList); } } num += Header.QuoteAndFold(stream, mimeStringList, 4026531840U, false, mimeStringList.Length > 0, encodingOptions.AllowUTF8, 0, ref currentLineLength, ref scratchBuffer); return(num + Header.WriteLineEnd(stream, ref currentLineLength)); }
internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = base.WriteName(stream, ref scratchBuffer); currentLineLength.IncrementBy((int)num); if (!base.IsDirty && base.RawLength != 0 && base.IsProtected) { long num2 = Header.WriteLines(base.Lines, stream); num += num2; currentLineLength.SetAs(0); return(num); } if (!this.parsed) { this.Parse(); } num += DateHeader.WriteDateHeaderValue(stream, this.utcDateTime, this.timeZoneOffset, ref currentLineLength); currentLineLength.SetAs(0); return(num); }
internal virtual long WriteValue(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = 0L; string value = this.Value; if (value != null) { int num2 = ByteString.StringToBytesCount(value, encodingOptions.AllowUTF8) + 1; if (scratchBuffer == null || scratchBuffer.Length < num2) { scratchBuffer = new byte[Math.Max(998, num2)]; } scratchBuffer[0] = 32; int num3 = ByteString.StringToBytes(value, scratchBuffer, 1, encodingOptions.AllowUTF8); stream.Write(scratchBuffer, 0, num3 + 1); num += (long)(num3 + 1); currentLineLength.IncrementBy(value.Length + 1, num3 + 1); } return(num); }
// Token: 0x06000302 RID: 770 RVA: 0x00010A58 File Offset: 0x0000EC58 internal override long WriteTo(Stream stream, EncodingOptions encodingOptions, MimeOutputFilter filter, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { MimeStringList fragments = this.valueFragments; long num = 0L; if (this.valueFragments.Length == 0 && this.decodedValue != null && 0 < this.decodedValue.Length) { fragments = this.EncodeValue(this.decodedValue, encodingOptions); this.valueFragments = fragments; } else if ((byte)(EncodingFlags.ForceReencode & encodingOptions.EncodingFlags) != 0 && 0 >= this.segmentNumber) { fragments = this.EncodeValue(this.Value, encodingOptions); } bool flag = false; if (this.IsQuotingReqired() || fragments.Length == 0) { flag = true; } else { for (int i = 0; i < fragments.Count; i++) { MimeString str = fragments[i]; int num2 = 0; int num3 = ValueParser.ParseToken(str, out num2, encodingOptions.AllowUTF8); if (268435456U != str.Mask && str.Length != num3) { flag = true; break; } } } MimeNode mimeNode = null; if (this.segmentNumber == 0) { mimeNode = base.FirstChild; while (mimeNode != null && !(mimeNode is MimeParameter)) { mimeNode = mimeNode.NextSibling; } } MimeString mimeString = ((this.segmentNumber == 0 && mimeNode != null) || 0 < this.segmentNumber) ? new MimeString(this.segmentNumber.ToString()) : default(MimeString); if (1 < currentLineLength.InChars) { int num4 = 1 + this.paramName.Length + 1; byte[] sz = fragments.GetSz(); int num5 = ByteString.BytesToCharCount(sz, encodingOptions.AllowUTF8); if (mimeString.Length != 0) { num4 += 1 + mimeString.Length; } if (this.valueEncoded) { num4++; } int num6 = num5; if (flag) { num6 += 2; } if (base.NextSibling != null) { if (num5 == 0) { num4++; } else { num6++; } } num6 += num4; if (currentLineLength.InChars + num6 > 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); } } int num7 = ByteString.StringToBytesCount(this.paramName, false); if (scratchBuffer == null || scratchBuffer.Length < num7) { scratchBuffer = new byte[Math.Max(998, num7)]; } int num8 = ByteString.StringToBytes(this.paramName, scratchBuffer, 0, false); stream.Write(scratchBuffer, 0, num8); num += (long)num8; currentLineLength.IncrementBy(this.paramName.Length, num8); if (mimeString.Length != 0) { stream.Write(MimeString.Asterisk, 0, MimeString.Asterisk.Length); num += (long)MimeString.Asterisk.Length; currentLineLength.IncrementBy(MimeString.Asterisk.Length); mimeString.WriteTo(stream); num += (long)mimeString.Length; currentLineLength.IncrementBy(mimeString.Length); } if (this.valueEncoded) { stream.Write(MimeString.Asterisk, 0, MimeString.Asterisk.Length); num += (long)MimeString.Asterisk.Length; currentLineLength.IncrementBy(MimeString.Asterisk.Length); } stream.Write(MimeString.EqualTo, 0, MimeString.EqualTo.Length); num += (long)MimeString.EqualTo.Length; currentLineLength.IncrementBy(MimeString.EqualTo.Length); int num9 = 0; if (base.NextSibling != null) { num9++; } num += Header.QuoteAndFold(stream, fragments, 4026531839U, flag, false, encodingOptions.AllowUTF8, num9, ref currentLineLength, ref scratchBuffer); int num10 = 0; while (mimeNode != null) { MimeParameter mimeParameter = mimeNode as MimeParameter; if (mimeParameter != null) { num10++; mimeParameter.segmentNumber = num10; stream.Write(MimeString.Semicolon, 0, MimeString.Semicolon.Length); num += (long)MimeString.Semicolon.Length; currentLineLength.IncrementBy(MimeString.Semicolon.Length); num += Header.WriteLineEnd(stream, ref currentLineLength); stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); num += mimeNode.WriteTo(stream, encodingOptions, null, ref currentLineLength, ref scratchBuffer); } mimeNode = mimeNode.NextSibling; } return(num); }
internal static long QuoteAndFold(Stream stream, MimeStringList fragments, uint inputMask, bool quoteOutput, bool addSpaceAtStart, bool allowUTF8, int lastLineReserve, ref MimeStringLength currentLineLength, ref byte[] scratchBuffer) { long num = 0L; Header.LineBuffer lineBuffer = default(Header.LineBuffer); lineBuffer.Length = new MimeStringLength(0); lineBuffer.LengthTillLastLWSP = new MimeStringLength(-1); if (scratchBuffer == null || scratchBuffer.Length < 998) { scratchBuffer = new byte[998]; } lineBuffer.Bytes = scratchBuffer; MimeScan.Token token = quoteOutput ? (MimeScan.Token.Spec | MimeScan.Token.Fwsp) : MimeScan.Token.Fwsp; bool flag = false; if (addSpaceAtStart && currentLineLength.InBytes != 0) { num += Header.WriteToken(Header.Space, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); flag = true; } if (quoteOutput) { num += Header.WriteToken(Header.DoubleQuote, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); } for (int i = 0; i < fragments.Count; i++) { MimeString mimeString = fragments[i]; int num2 = 0; int num3 = 0; byte[] data = mimeString.GetData(out num2, out num3); if ((mimeString.Mask & inputMask) != 0U) { do { int valueInChars = 0; int num4 = MimeScan.FindNextOf(token, data, num2, num3, out valueInChars, allowUTF8); if (num4 > 0) { num += Header.WriteToken(data, num2, new MimeStringLength(valueInChars, num4), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); num2 += num4; num3 -= num4; } if (num3 != 0) { byte b = data[num2]; if ((b == 34 || b == 92) && (mimeString.Mask & 3758096383U) != 0U) { num += Header.WriteToken(new byte[] { 92, data[num2] }, 0, new MimeStringLength(2), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); num2++; num3--; } else { num += Header.WriteToken(new byte[] { data[num2] }, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); num2++; num3--; } } }while (num3 != 0); } } if (quoteOutput) { num += Header.WriteToken(Header.DoubleQuote, 0, new MimeStringLength(1), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); } if (lastLineReserve > 0) { num += Header.WriteToken(null, 0, new MimeStringLength(lastLineReserve), stream, ref currentLineLength, ref lineBuffer, ref flag, allowUTF8); } if (lineBuffer.Length.InBytes > 0) { stream.Write(lineBuffer.Bytes, 0, lineBuffer.Length.InBytes); num += (long)lineBuffer.Length.InBytes; currentLineLength.IncrementBy(lineBuffer.Length); } return(num); }
private static long WriteToken(byte[] token, int tokenOffset, MimeStringLength tokenLength, Stream stream, ref MimeStringLength currentLineLength, ref Header.LineBuffer lineBuffer, ref bool autoAddedLastLWSP, bool allowUTF8) { long num = 0L; bool flag = token != null && tokenLength.InChars == 1 && MimeScan.IsFWSP(token[tokenOffset]); if (!flag && currentLineLength.InChars + lineBuffer.Length.InChars + tokenLength.InChars > 78 && lineBuffer.LengthTillLastLWSP.InBytes >= 0) { if (lineBuffer.LengthTillLastLWSP.InBytes > 0) { stream.Write(lineBuffer.Bytes, 0, lineBuffer.LengthTillLastLWSP.InBytes); num += (long)lineBuffer.LengthTillLastLWSP.InBytes; currentLineLength.IncrementBy(lineBuffer.LengthTillLastLWSP); } if (currentLineLength.InBytes > 0) { num += Header.WriteLineEnd(stream, ref currentLineLength); } if (autoAddedLastLWSP) { autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.IncrementBy(1); } if (lineBuffer.LengthTillLastLWSP.InBytes != lineBuffer.Length.InBytes) { Buffer.BlockCopy(lineBuffer.Bytes, lineBuffer.LengthTillLastLWSP.InBytes, lineBuffer.Bytes, 0, lineBuffer.Length.InBytes - lineBuffer.LengthTillLastLWSP.InBytes); lineBuffer.Length.DecrementBy(lineBuffer.LengthTillLastLWSP); if (lineBuffer.Length.InBytes > 0 && MimeScan.IsFWSP(lineBuffer.Bytes[0])) { lineBuffer.LengthTillLastLWSP.SetAs(0); } else { lineBuffer.LengthTillLastLWSP.SetAs(-1); } } else { lineBuffer.Length.SetAs(0); lineBuffer.LengthTillLastLWSP.SetAs(-1); } bool flag2 = false; if (lineBuffer.Length.InBytes > 0) { if (!MimeScan.IsFWSP(lineBuffer.Bytes[0])) { flag2 = true; } } else if (!flag) { flag2 = true; } if (flag2) { stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); } } if (currentLineLength.InBytes + lineBuffer.Length.InBytes + tokenLength.InBytes > 998) { if (lineBuffer.Length.InBytes > 0) { stream.Write(lineBuffer.Bytes, 0, lineBuffer.Length.InBytes); num += (long)lineBuffer.Length.InBytes; currentLineLength.IncrementBy(lineBuffer.Length); lineBuffer.Length.SetAs(0); autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.SetAs(-1); } if (token != null) { while (currentLineLength.InBytes + tokenLength.InBytes > 998) { int num2 = Math.Max(0, 998 - currentLineLength.InBytes); int num3 = 0; int num4 = 0; if (allowUTF8) { int num5; for (int i = 0; i < tokenLength.InBytes; i += num5) { byte b = token[tokenOffset + i]; num5 = 1; if (b >= 128 && !MimeScan.IsUTF8NonASCII(token, tokenOffset + i, tokenOffset + tokenLength.InBytes, out num5)) { num5 = 1; } if (num4 + num5 > num2) { break; } num3++; num4 += num5; } } else { num3 = num2; num4 = num2; } stream.Write(token, tokenOffset, num4); num += (long)num4; currentLineLength.IncrementBy(num3, num4); tokenOffset += num4; tokenLength.DecrementBy(num3, num4); num += Header.WriteLineEnd(stream, ref currentLineLength); if (!flag) { stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); } } } } if (token != null) { Buffer.BlockCopy(token, tokenOffset, lineBuffer.Bytes, lineBuffer.Length.InBytes, tokenLength.InBytes); if (flag && (lineBuffer.Length.InBytes == 0 || !MimeScan.IsFWSP(lineBuffer.Bytes[lineBuffer.Length.InBytes - 1]))) { autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.SetAs(lineBuffer.Length); } lineBuffer.Length.IncrementBy(tokenLength); } return(num); }