예제 #1
0
 // Token: 0x06000339 RID: 825 RVA: 0x000125A8 File Offset: 0x000107A8
 public void SetContentType(MajorContentType contentType, MimeString boundaryValue)
 {
     if (contentType == MajorContentType.Multipart)
     {
         int    srcOffset;
         int    num;
         byte[] data  = boundaryValue.GetData(out srcOffset, out num);
         int    num2  = MimeString.TwoDashes.Length + num + MimeString.TwoDashes.Length;
         byte[] array = new byte[num2];
         int    num3  = MimeString.TwoDashes.Length;
         Buffer.BlockCopy(MimeString.TwoDashes, 0, array, 0, num3);
         Buffer.BlockCopy(data, srcOffset, array, num3, num);
         num3            += num;
         this.boundaryCrc = ByteString.ComputeCrc(array, 0, num3);
         Buffer.BlockCopy(MimeString.TwoDashes, 0, array, num3, MimeString.TwoDashes.Length);
         num3 += MimeString.TwoDashes.Length;
         this.endBoundaryCrc = ByteString.ComputeCrc(array, 0, num3);
         this.boundaryValue  = new MimeString(array, 0, num3);
     }
     else
     {
         this.boundaryValue  = default(MimeString);
         this.boundaryCrc    = 0U;
         this.endBoundaryCrc = 0U;
     }
     this.contentType = contentType;
 }
예제 #2
0
        // 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);
        }
예제 #3
0
 public ValueIterator(MimeStringList lines, uint linesMask)
 {
     this.lines     = lines;
     this.linesMask = linesMask;
     this.lineStart = (this.lineEnd = (this.currentLine = (this.currentOffset = 0)));
     this.lineBytes = null;
     this.endLine   = this.lines.Count;
     this.endOffset = 0;
     while (this.currentLine != this.endLine)
     {
         MimeString mimeString = this.lines[this.currentLine];
         if ((mimeString.Mask & this.linesMask) != 0U)
         {
             int num;
             this.lineBytes     = mimeString.GetData(out this.lineStart, out num);
             this.lineEnd       = this.lineStart + num;
             this.currentOffset = this.lineStart;
             return;
         }
         this.currentLine++;
     }
 }
예제 #4
0
        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);
        }