Beispiel #1
0
        private static string DeencapsulateString(string encapsulated)
        {
            StringBuilder stringBuilder = new StringBuilder(encapsulated.Length);
            int           i             = 0;

            while (i < encapsulated.Length)
            {
                char c = encapsulated[i];
                if (c != '+')
                {
                    if (c != '_')
                    {
                        goto IL_48;
                    }
                    stringBuilder.Append('/');
                }
                else
                {
                    char value;
                    if (!SmtpProxyAddress.ConvertTwoHexCharToChar(encapsulated, i + 1, out value))
                    {
                        goto IL_48;
                    }
                    stringBuilder.Append(value);
                    i += 2;
                }
IL_56:
                i++;
                continue;
IL_48:
                stringBuilder.Append(encapsulated[i]);
                goto IL_56;
            }
            return(stringBuilder.ToString());
        }
Beispiel #2
0
        private static string DeencapsulateUTF8String(string encapsulated)
        {
            byte[] array = new byte[encapsulated.Length];
            int    num   = 0;
            int    i     = 0;

            while (i < encapsulated.Length)
            {
                char c = encapsulated[i];
                if (c != '+')
                {
                    if (c != '_')
                    {
                        goto IL_4E;
                    }
                    array[num] = 47;
                    num++;
                }
                else
                {
                    char c2;
                    if (!SmtpProxyAddress.ConvertTwoHexCharToChar(encapsulated, i + 1, out c2))
                    {
                        goto IL_4E;
                    }
                    array[num] = (byte)c2;
                    i         += 2;
                    num++;
                }
IL_6D:
                i++;
                continue;
IL_4E:
                if (encapsulated[i] > 'ÿ')
                {
                    return(null);
                }
                array[num] = (byte)encapsulated[i];
                num++;
                goto IL_6D;
            }
            string result;

            try
            {
                Encoding encoding = new UTF8Encoding(false, true);
                result = encoding.GetString(array, 0, num);
            }
            catch (DecoderFallbackException)
            {
                result = null;
            }
            return(result);
        }