DecodeURIComponent() public static method

public static DecodeURIComponent ( string str ) : string
str string
return string
Esempio n. 1
0
        public virtual string Link(string href, string title, string text)
        {
            if (Options.Sanitize)
            {
                string prot = null;

                try
                {
                    prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(href)), @"[^\w:]", String.Empty).ToLower();
                }
                catch (Exception)
                {
                    return(String.Empty);
                }

                if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0)
                {
                    return(String.Empty);
                }
            }

            var @out = "<a href=\"" + href + "\"";

            if (!String.IsNullOrEmpty(title))
            {
                @out += " title=\"" + title + "\"";
            }

            @out += ">" + text + "</a>";
            return(@out);
        }
Esempio n. 2
0
        public virtual string Link(string href, string title, string text)
        {
            if (Options.Sanitize)
            {
                string prot = null;

                try
                {
                    prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(href)), @"[^\w:]", String.Empty).ToLower();
                }
                catch (Exception)
                {
                    return(string.Empty);
                }

                if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0)
                {
                    return(string.Empty);
                }
            }

            var output = $"<a href='{href}'";

            if (!string.IsNullOrEmpty(title))
            {
                output += $" title='{title}'";
            }

            if (this.Options.ExternalLinks && (href.StartsWith("//") || href.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)))
            {
                output += " target='_blank' rel='nofollow'";
            }

            output += $">{text}</a>";
            return(output);
        }