public static string UnEscapeURL(string s, Encoding e)
        {
            bool   flag = s == null;
            string result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = s.IndexOf('%') == -1 && s.IndexOf('+') == -1;
                if (flag2)
                {
                    result = s;
                }
                else
                {
                    byte[] bytes  = e.GetBytes(s);
                    byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                    result = e.GetString(bytes2);
                }
            }
            return(result);
        }
Esempio n. 2
0
        internal static string MakeInitialUrl(string targetUrl, string localUrl)
        {
            string result;

            if (targetUrl.StartsWith("jar:file://"))
            {
                result = targetUrl;
            }
            else if (targetUrl.StartsWith("blob:http"))
            {
                result = targetUrl;
            }
            else
            {
                Uri uri  = new Uri(localUrl);
                Uri uri2 = null;
                if (targetUrl[0] == '/')
                {
                    uri2 = new Uri(uri, targetUrl);
                }
                if (uri2 == null && WebRequestUtils.domainRegex.IsMatch(targetUrl))
                {
                    targetUrl = uri.Scheme + "://" + targetUrl;
                }
                FormatException ex = null;
                try
                {
                    if (uri2 == null && targetUrl[0] != '.')
                    {
                        uri2 = new Uri(targetUrl);
                    }
                }
                catch (FormatException ex2)
                {
                    ex = ex2;
                }
                if (uri2 == null)
                {
                    try
                    {
                        uri2 = new Uri(uri, targetUrl);
                    }
                    catch (FormatException)
                    {
                        throw ex;
                    }
                }
                if (targetUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
                {
                    result = ((!targetUrl.Contains("%")) ? targetUrl : WWWTranscoder.URLDecode(targetUrl, Encoding.UTF8));
                }
                else
                {
                    result = ((!targetUrl.Contains("%")) ? uri2.AbsoluteUri : uri2.OriginalString);
                }
            }
            return(result);
        }
Esempio n. 3
0
 public static string UnEscapeURL(string s, Encoding e)
 {
     if (s == null)
     {
         return(null);
     }
     if ((s.IndexOf('%') == -1) && (s.IndexOf('+') == -1))
     {
         return(s);
     }
     return(WWWTranscoder.URLDecode(s, e));
 }
        public static string UnEscapeURL(string s, Encoding e)
        {
            if (null == s)
            {
                return(null);
            }

            if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                return(s);
            }

            var bytes        = e.GetBytes(s);
            var decodedBytes = WWWTranscoder.URLDecode(bytes);

            return(e.GetString(decodedBytes));
        }
Esempio n. 5
0
        public static string UnEscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                result = WWWTranscoder.URLDecode(s, e);
            }
            return(result);
        }
        public static string UnEscapeURL(string s, Encoding e)
        {
            string result;

            if (s == null)
            {
                result = null;
            }
            else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
            {
                result = s;
            }
            else
            {
                byte[] bytes  = Encoding.UTF8.GetBytes(s);
                byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                result = e.GetString(bytes2);
            }
            return(result);
        }
        internal static string MakeUriString(Uri targetUri, string targetUrl, bool prependingProtocol)
        {
            string result;

            if (targetUrl.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
            {
                if (targetUrl.Contains("%"))
                {
                    byte[] bytes  = Encoding.UTF8.GetBytes(targetUrl);
                    byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
                    result = Encoding.UTF8.GetString(bytes2);
                }
                else
                {
                    result = targetUrl;
                }
            }
            else if (targetUrl.Contains("%"))
            {
                result = targetUri.OriginalString;
            }
            else
            {
                string scheme = targetUri.Scheme;
                if (!prependingProtocol && targetUrl.Length >= scheme.Length + 2 && targetUrl[scheme.Length + 1] != '/')
                {
                    StringBuilder stringBuilder = new StringBuilder(scheme, targetUrl.Length);
                    stringBuilder.Append(':');
                    stringBuilder.Append(targetUri.PathAndQuery);
                    stringBuilder.Append(targetUri.Fragment);
                    result = stringBuilder.ToString();
                }
                else
                {
                    result = targetUri.AbsoluteUri;
                }
            }
            return(result);
        }
Esempio n. 8
0
 private static string URLDecode(string encoded)
 {
     byte[] bytes  = Encoding.UTF8.GetBytes(encoded);
     byte[] bytes2 = WWWTranscoder.URLDecode(bytes);
     return(Encoding.UTF8.GetString(bytes2));
 }