// Token: 0x060002FE RID: 766 RVA: 0x0001097F File Offset: 0x0000EB7F
 internal static string CorrectValue(string value)
 {
     if (-1 == value.IndexOfAny(MimeParameter.ControlCharacters))
     {
         return(value);
     }
     return(MimeParameter.CorrectValue(value.ToCharArray()));
 }
 // Token: 0x06000300 RID: 768 RVA: 0x000109E4 File Offset: 0x0000EBE4
 internal bool FallBackIfRequired(byte[] bytes, DecodingOptions decodingOptions, out string value)
 {
     if ((DecodingFlags.FallbackToRaw & decodingOptions.DecodingFlags) != DecodingFlags.None)
     {
         if (bytes == null)
         {
             value = string.Empty;
         }
         else
         {
             value = ByteString.BytesToString(bytes, decodingOptions.AllowUTF8);
             if ((DecodingFlags.AllowControlCharacters & decodingOptions.DecodingFlags) == DecodingFlags.None)
             {
                 value = MimeParameter.CorrectValue(value);
             }
         }
         return(true);
     }
     value = null;
     return(false);
 }
        // Token: 0x0600030B RID: 779 RVA: 0x000112A8 File Offset: 0x0000F4A8
        private bool TryDecodeRfc2231(ref DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
        {
            decodingResults = default(DecodingResults);
            decodingResults.EncodingScheme = EncodingScheme.Rfc2231;
            Charset charset = null;

            byte[] sz  = this.valueFragments.GetSz(4026531839U);
            int    num = 0;

            if (this.valueEncoded)
            {
                int num2 = (sz == null) ? -1 : ByteString.IndexOf(sz, 39, 0, sz.Length);
                if (-1 < num2 && num2 < sz.Length - 1)
                {
                    int num3 = ByteString.IndexOf(sz, 39, ++num2, sz.Length - num2);
                    if (-1 < num3)
                    {
                        decodingResults.CharsetName = ByteString.BytesToString(sz, 0, num2 - 1, false);
                        decodingResults.CultureName = ByteString.BytesToString(sz, num2, num3 - num2, false);
                        if (!Charset.TryGetCharset(decodingResults.CharsetName, out charset))
                        {
                            decodingResults.DecodingFailed = true;
                            return(this.FallBackIfRequired(sz, decodingOptions, out value));
                        }
                        num = num3 + 1;
                    }
                }
            }
            if (charset == null)
            {
                charset = decodingOptions.Charset;
                if (charset == null)
                {
                    charset = DecodingOptions.DefaultCharset;
                }
            }
            decodingResults.CharsetName = charset.Name;
            Encoding encoding;

            if (!charset.TryGetEncoding(out encoding))
            {
                decodingResults.DecodingFailed = true;
                return(this.FallBackIfRequired(sz, decodingOptions, out value));
            }
            int num4 = this.valueFragments.Length - num;

            for (MimeNode mimeNode = base.FirstChild; mimeNode != null; mimeNode = mimeNode.NextSibling)
            {
                MimeParameter mimeParameter = mimeNode as MimeParameter;
                if (mimeParameter != null)
                {
                    num4 += mimeParameter.RawLength;
                }
            }
            byte[] array = new byte[num4];
            int    num5  = 0;

            if (sz != null && num < sz.Length)
            {
                num5 += this.DecodeRfc2231Octets(this.valueEncoded, sz, num, array, 0);
            }
            for (MimeNode mimeNode = base.FirstChild; mimeNode != null; mimeNode = mimeNode.NextSibling)
            {
                MimeParameter mimeParameter2 = mimeNode as MimeParameter;
                if (mimeParameter2 != null)
                {
                    byte[] rawValue = mimeParameter2.RawValue;
                    if (rawValue != null)
                    {
                        num5 += this.DecodeRfc2231Octets(mimeParameter2.valueEncoded, mimeParameter2.RawValue, 0, array, num5);
                    }
                }
            }
            value = ((num5 != 0) ? encoding.GetString(array, 0, num5) : string.Empty);
            if ((DecodingFlags.AllowControlCharacters & decodingOptions.DecodingFlags) == DecodingFlags.None)
            {
                value = MimeParameter.CorrectValue(value);
            }
            return(true);
        }