Exemple #1
0
 public bool TryGetValue(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
 {
     this.AssertGood(true);
     if (this.reader.ReaderState == MimeReaderState.HeaderStart)
     {
         this.reader.TryCompleteCurrentHeader(true);
     }
     if (this.reader.CurrentHeaderObject != null)
     {
         TextHeader textHeader = this.reader.CurrentHeaderObject as TextHeader;
         if (textHeader != null)
         {
             value = textHeader.GetDecodedValue(decodingOptions, out decodingResults);
             if (decodingResults.DecodingFailed)
             {
                 value = null;
                 return(false);
             }
             return(true);
         }
         else
         {
             value = this.reader.CurrentHeaderObject.Value;
         }
     }
     else
     {
         value = null;
     }
     decodingResults = default(DecodingResults);
     return(true);
 }
 // Token: 0x060002FD RID: 765 RVA: 0x000108E8 File Offset: 0x0000EAE8
 public bool TryGetValue(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
 {
     if (decodingOptions.Charset == null)
     {
         decodingOptions.Charset = base.GetDefaultHeaderDecodingCharset(null, null);
     }
     if ((DecodingFlags.Rfc2231 & decodingOptions.DecodingFlags) != DecodingFlags.None)
     {
         if (this.segmentNumber == 0)
         {
             return(this.TryDecodeRfc2231(ref decodingOptions, out decodingResults, out value));
         }
         if (0 < this.segmentNumber)
         {
             throw new NotSupportedException(Strings.CantGetValueOfRfc2231ContinuationSegment);
         }
     }
     if (this.valueFragments.Length == 0)
     {
         decodingResults = default(DecodingResults);
         value           = ((this.decodedValue != null) ? this.decodedValue : string.Empty);
         return(true);
     }
     return(MimeCommon.TryDecodeValue(this.valueFragments, 4026531839U, decodingOptions, out decodingResults, out value));
 }
 // Token: 0x06000550 RID: 1360 RVA: 0x0001D120 File Offset: 0x0001B320
 public bool TryGetValue(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
 {
     value = this.GetDecodedValue(decodingOptions, out decodingResults);
     if (decodingResults.DecodingFailed)
     {
         value = null;
         return(false);
     }
     return(true);
 }
Exemple #4
0
 // Token: 0x0600019D RID: 413 RVA: 0x00007500 File Offset: 0x00005700
 public bool TryGetDisplayName(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string displayName)
 {
     if (this.displayNameFragments.Count == 0)
     {
         displayName     = this.decodedDisplayName;
         decodingResults = default(DecodingResults);
         return(true);
     }
     if (decodingOptions.Charset == null)
     {
         decodingOptions.Charset = base.GetDefaultHeaderDecodingCharset(null, null);
     }
     return(MimeCommon.TryDecodeValue(this.displayNameFragments, 4026531839U, decodingOptions, out decodingResults, out displayName));
 }
        // Token: 0x06000551 RID: 1361 RVA: 0x0001D13C File Offset: 0x0001B33C
        internal string GetDecodedValue(DecodingOptions decodingOptions, out DecodingResults decodingResults)
        {
            string result = null;

            if (base.Lines.Length == 0)
            {
                result          = ((this.decodedValue != null) ? this.decodedValue : string.Empty);
                decodingResults = default(DecodingResults);
                return(result);
            }
            if (decodingOptions.Charset == null)
            {
                decodingOptions.Charset = base.GetDefaultHeaderDecodingCharset(null, null);
            }
            if (!MimeCommon.TryDecodeValue(base.Lines, 4026531840U, decodingOptions, out decodingResults, out result))
            {
                result = null;
            }
            return(result);
        }
        // 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);
        }
 // Token: 0x06000448 RID: 1096 RVA: 0x00018FB1 File Offset: 0x000171B1
 public bool TryGetDisplayName(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string displayName)
 {
     this.AssertGood(true);
     return(this.reader.TryReadDisplayName(this.topLevel, decodingOptions, out decodingResults, out displayName));
 }
 public bool TryGetValue(DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
 {
     this.AssertGood(true);
     return(this.reader.TryReadParameterValue(decodingOptions, out decodingResults, out value));
 }
 // Token: 0x0600024D RID: 589 RVA: 0x0000AE62 File Offset: 0x00009062
 internal static void ThrowDecodingFailedException(ref DecodingResults decodingResults)
 {
     Charset.GetEncoding(decodingResults.CharsetName);
     throw new ExchangeDataException("internal value decoding error");
 }
        // Token: 0x0600024C RID: 588 RVA: 0x0000AD74 File Offset: 0x00008F74
        internal static bool TryDecodeValue(MimeStringList lines, uint linesMask, DecodingOptions decodingOptions, out DecodingResults decodingResults, out string value)
        {
            decodingResults = default(DecodingResults);
            if (lines.GetLength(linesMask) == 0)
            {
                value = string.Empty;
                return(true);
            }
            DecodingFlags decodingFlags          = decodingOptions.DecodingFlags;
            bool          flag                   = DecodingFlags.None != (DecodingFlags.FallbackToRaw & decodingFlags);
            bool          allowControlCharacters = DecodingFlags.None != (DecodingFlags.AllowControlCharacters & decodingFlags);
            bool          enable                 = false;
            bool          enableJisDetection     = false;
            bool          enableUtf8Detection    = false;
            bool          enableDbcsDetection    = false;
            Charset       defaultCharset         = null;
            ValueDecoder  valueDecoder           = new ValueDecoder(lines, linesMask);

            if ((decodingFlags & DecodingFlags.AllEncodings) == DecodingFlags.None)
            {
                if (!flag)
                {
                    defaultCharset = Charset.ASCII;
                }
            }
            else
            {
                enable              = (DecodingFlags.None != (DecodingFlags.Rfc2047 & decodingFlags));
                enableJisDetection  = (DecodingFlags.None != (DecodingFlags.Jis & decodingFlags));
                enableUtf8Detection = (DecodingFlags.None != (DecodingFlags.Utf8 & decodingFlags));
                enableDbcsDetection = (DecodingFlags.None != (DecodingFlags.Dbcs & decodingFlags));
                defaultCharset      = decodingOptions.Charset;
            }
            string         charsetName;
            string         cultureName;
            EncodingScheme encodingScheme;
            bool           flag2 = valueDecoder.TryDecodeValue(defaultCharset, flag, allowControlCharacters, enable, enableJisDetection, enableUtf8Detection, enableDbcsDetection, out charsetName, out cultureName, out encodingScheme, out value);

            decodingResults.EncodingScheme = encodingScheme;
            decodingResults.CharsetName    = charsetName;
            decodingResults.CultureName    = cultureName;
            decodingResults.DecodingFailed = !flag2;
            return(flag2);
        }