Example #1
0
        private string HyperLinksFormatMatchEvaluator(Match m)
        {
            //TODO: check the URL
            string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "", UseRestrictedMode);

            if (m.Groups["title"].Length > 0)
            {
                atts += " title=\"" + m.Groups["title"].Value + "\"";
            }
            string linkText = m.Groups["text"].Value.Trim(' ');

            // Validate the URL.
            string url = TextileGlobals.EncodeHTMLLink(m.Groups["url"].Value) + m.Groups["slash"].Value;

            if (url.Contains("\"")) // Disable the URL if someone's trying a cheap hack.
            {
                url = "#";
            }

            string str = m.Groups["pre"].Value + "<a ";

            if (m_rel != null && m_rel != string.Empty)
            {
                str += "ref=\"" + m_rel + "\" ";
            }
            str += "href=\"" + url + "\"" +
                   atts +
                   ">" + linkText + "</a>" + m.Groups["post"].Value;
            return(str);
        }
        private string HyperLinksFormatMatchEvaluator(Match m)
        {
            var atts = BlockAttributesParser.Parse(m.Groups["atts"].Value, "", UseRestrictedMode);

            if (m.Groups["title"].Length > 0)
            {
                atts += $" title=\"{m.Groups["title"].Value}\"";
            }

            var linkText = m.Groups["text"].Value.Trim(' ');

            var url = TextileGlobals.EncodeHTMLLink(m.Groups["url"].Value) + m.Groups["slash"].Value;

            if (url.Contains("\""))
            {
                // Disable the URL if someone's trying a cheap hack.
                url = "#";
            }

            var str = $"{m.Groups["pre"].Value}<a ";

            if (_rel != null && _rel != string.Empty)
            {
                str += $"ref=\"{_rel}\" ";
            }

            str += $"href=\"{url}\"{atts}>{linkText}</a>{m.Groups["post"].Value}";

            return(str);
        }
Example #3
0
        private string ImageFormatMatchEvaluator(Match m)
        {
            var atts = new StringBuilder(BlockAttributesParser.Parse(m.Groups["atts"].Value, "", UseRestrictedMode));

            if (m.Groups["algn"].Length > 0)
            {
                atts.Append($" align=\"{TextileGlobals.ImageAlign[m.Groups["algn"].Value]}\"");
            }

            if (m.Groups["title"].Length > 0)
            {
                atts.Append($" title=\"{m.Groups["title"].Value}\"");
                atts.Append($" alt=\"{m.Groups["title"].Value}\"");
            }
            else
            {
                atts.Append(" alt=\"\"");
            }

            // Validate the URL.
            var url = m.Groups["url"].Value;

            if (url.Contains("\""))
            {
                // Disable the URL if someone's trying a cheap hack.
                url = "#";
            }

            string res = $"<img src=\"{url}\"{atts} />";

            if (m.Groups["href"].Length > 0)
            {
                var href     = m.Groups["href"].Value;
                var end      = string.Empty;
                var endMatch = HrefRegex.Match(href);
                if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value))
                {
                    href = href.Substring(0, href.Length - 1);
                    end  = endMatch.Groups["end"].Value;
                }

                res = $"<a href=\"{TextileGlobals.EncodeHTMLLink(href)}\">{res}</a>{end}";
            }

            return(res);
        }
        private string ImageFormatMatchEvaluator(Match m)
        {
            string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "", UseRestrictedMode);

            if (m.Groups["algn"].Length > 0)
            {
                atts += " align=\"" + TextileGlobals.ImageAlign[m.Groups["algn"].Value] + "\"";
            }
            if (m.Groups["title"].Length > 0)
            {
                atts += " title=\"" + m.Groups["title"].Value + "\"";
                atts += " alt=\"" + m.Groups["title"].Value + "\"";
            }
            else
            {
                atts += " alt=\"\"";
            }
            // Get Image Size?

            // Validate the URL.
            string url = m.Groups["url"].Value;

            if (url.Contains("\"")) // Disable the URL if someone's trying a cheap hack.
            {
                url = "#";
            }

            string res = "<img src=\"" + url + "\"" + atts + " />";

            if (m.Groups["href"].Length > 0)
            {
                string href     = m.Groups["href"].Value;
                string end      = string.Empty;
                Match  endMatch = HrefRegex.Match(href);
                if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value))
                {
                    href = href.Substring(0, href.Length - 1);
                    end  = endMatch.Groups["end"].Value;
                }
                res = "<a href=\"" + TextileGlobals.EncodeHTMLLink(href) + "\">" + res + "</a>" + end;
            }

            return(res);
        }