コード例 #1
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="name"></param>
        public HtmlTag(string name, IHtmlFilter filter)
        {
            this.filter = filter;
            if (name == null)
            {
                name = String.Empty;
            }
            this.rawName = name.Trim();

            if (this.rawName.StartsWith("!") ||
                this.rawName.StartsWith("?") ||
                this.rawName.StartsWith("%"))
            {
                this.tagType = HtmlTagType.Unparsed;
            }
            else if (this.rawName.StartsWith("/"))
            {
                this.tagType = HtmlTagType.EndTag;
                this.rawName = this.rawName.Substring(1);
            }
            else if (HtmlTag.FullTagRequired(this.TagName))             // this.TagName is lowercase
            {
                this.tagType = HtmlTagType.FullTag;
            }
            else
            {
                this.tagType = HtmlTagType.BeginTag;
            }
        }
コード例 #2
0
ファイル: RichText.cs プロジェクト: JacksonBruce/AntiXssUF
 /// <summary>
 /// 实例化一个富文本对象
 /// </summary>
 /// <param name="source">未被过滤的源文本</param>
 /// <param name="htmlFilter">html过滤器</param>
 public RichText(string source, IHtmlFilter htmlFilter)
 {
     this.source     = source;
     this.htmlFilter = htmlFilter ?? throw new ArgumentNullException(nameof(htmlFilter));
 }
コード例 #3
0
ファイル: HtmlTag.cs プロジェクト: pocket-playlab/jsonfx-v1
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="name"></param>
        public HtmlTag(string name, IHtmlFilter filter)
        {
            this.filter = filter;
            if (name == null)
            {
                name = String.Empty;
            }
            this.rawName = name.Trim();

            if (this.rawName.StartsWith("!") ||
                this.rawName.StartsWith("?") ||
                this.rawName.StartsWith("%"))
            {
                this.tagType = HtmlTagType.Unparsed;
            }
            else if (this.rawName.StartsWith("/"))
            {
                this.tagType = HtmlTagType.EndTag;
                this.rawName = this.rawName.Substring(1);
            }
            else if (HtmlTag.FullTagRequired(this.TagName)) // this.TagName is lowercase
            {
                this.tagType = HtmlTagType.FullTag;
            }
            else
            {
                this.tagType = HtmlTagType.BeginTag;
            }
        }
コード例 #4
0
        /// <summary>
        /// Quick parsing utility for common usage.
        /// </summary>
        /// <param name="html">the source text</param>
        /// <param name="filter">a custom HtmlFilter</param>
        /// <param name="maxLength">the maximum text length</param>
        /// <returns>the filtered markup</returns>
        public static string Parse(string html, IHtmlFilter filter, int maxLength)
        {
            StringWriter writer = new StringWriter();

            HtmlDistiller parser = new HtmlDistiller(maxLength, filter);
            parser.HtmlWriter = new HtmlWriter(writer);
            parser.Parse(html);

            return writer.ToString();
        }
コード例 #5
0
 /// <summary>
 /// Quick parsing utility for common usage.
 /// </summary>
 /// <param name="html">the source text</param>
 /// <param name="filter">a custom HtmlFilter</param>
 /// <returns>the filtered markup</returns>
 public static string Parse(string html, IHtmlFilter filter)
 {
     return HtmlDistiller.Parse(html, filter, 0);
 }
コード例 #6
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="text">the text to parse</param>
 /// <param name="filter"></param>
 public HtmlDistiller(int maxLength, IHtmlFilter filter)
 {
     this.maxLength = maxLength;
     this.htmlFilter = filter;
 }
コード例 #7
0
ファイル: JumonyHandler.cs プロジェクト: ajayumi/Jumony
 /// <summary>引发 Rendered 事件</summary>
 protected virtual void OnRendered( HtmlRequestContext context, IHtmlFilter[] filters )
 {
   foreach ( var filter in filters.Reverse() )
   {
     try
     {
       filter.OnRendered( context );
     }
     catch { }
   }
 }
コード例 #8
0
ファイル: JumonyHandler.cs プロジェクト: ajayumi/Jumony
 /// <summary>引发 Processing 事件</summary>
 protected virtual void OnProcessing( HtmlRequestContext context, IHtmlFilter[] filters )
 {
   foreach ( var filter in filters )
   {
     try
     {
       filter.OnProcessing( context );
     }
     catch { }
   }
 }