Esempio n. 1
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public HtmlEncoder(ICodePointFilter filter)
     : this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public HtmlEncoder(ICodePointFilter filter)
     : this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
 }
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public JavaScriptStringEncoder(ICodePointFilter filter)
     : this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
 }
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public JavaScriptStringEncoder(ICodePointFilter filter)
     : this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Instantiates the filter by cloning the allow list of another <see cref="ICodePointFilter"/>.
 /// </summary>
 public CodePointFilter(ICodePointFilter other)
 {
     CodePointFilter otherAsCodePointFilter = other as CodePointFilter;
     if (otherAsCodePointFilter != null)
     {
         _allowedCharactersBitmap = otherAsCodePointFilter.GetAllowedCharacters();
     }
     else
     {
         _allowedCharactersBitmap = AllowedCharactersBitmap.CreateNew();
         AllowFilter(other);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Allows all characters specified by <paramref name="filter"/> through the filter.
 /// </summary>
 /// <returns>
 /// The 'this' instance.
 /// </returns>
 public CodePointFilter AllowFilter([NotNull] ICodePointFilter filter)
 {
     foreach (var allowedCodePoint in filter.GetAllowedCodePoints())
     {
         // If the code point can't be represented as a BMP character, skip it.
         char codePointAsChar = (char)allowedCodePoint;
         if (allowedCodePoint == codePointAsChar)
         {
             _allowedCharsBitmap.AllowCharacter(codePointAsChar);
         }
     }
     return(this);
 }
Esempio n. 7
0
        /// <summary>
        /// Instantiates the filter by cloning the allow list of another <see cref="ICodePointFilter"/>.
        /// </summary>
        public CodePointFilter(ICodePointFilter other)
        {
            CodePointFilter otherAsCodePointFilter = other as CodePointFilter;

            if (otherAsCodePointFilter != null)
            {
                _allowedCharactersBitmap = otherAsCodePointFilter.GetAllowedCharacters();
            }
            else
            {
                _allowedCharactersBitmap = AllowedCharactersBitmap.CreateNew();
                AllowFilter(other);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Allows all characters specified by <paramref name="filter"/> through the filter.
        /// </summary>
        /// <returns>
        /// The 'this' instance.
        /// </returns>
        public CodePointFilter AllowFilter(ICodePointFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            foreach (var allowedCodePoint in filter.GetAllowedCodePoints())
            {
                // If the code point can't be represented as a BMP character, skip it.
                char codePointAsChar = (char)allowedCodePoint;
                if (allowedCodePoint == codePointAsChar)
                {
                    _allowedCharactersBitmap.AllowCharacter(codePointAsChar);
                }
            }
            return(this);
        }
        /// <summary>
        /// Instantiates the filter by cloning the allow list of another <see cref="ICodePointFilter"/>.
        /// </summary>
        public CodePointFilter(ICodePointFilter other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            CodePointFilter otherAsCodePointFilter = other as CodePointFilter;
            if (otherAsCodePointFilter != null)
            {
                _allowedCharsBitmap = otherAsCodePointFilter.GetAllowedCharsBitmap();
            }
            else
            {
                _allowedCharsBitmap = AllowedCharsBitmap.CreateNew();
                AllowFilter(other);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Instantiates the filter by cloning the allow list of another <see cref="ICodePointFilter"/>.
        /// </summary>
        public CodePointFilter(ICodePointFilter other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            CodePointFilter otherAsCodePointFilter = other as CodePointFilter;

            if (otherAsCodePointFilter != null)
            {
                _allowedCharsBitmap = otherAsCodePointFilter.GetAllowedCharsBitmap();
            }
            else
            {
                _allowedCharsBitmap = AllowedCharsBitmap.CreateNew();
                AllowFilter(other);
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public HtmlEncoderOld(ICodePointFilter filter)
     : this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
 }
Esempio n. 12
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public HtmlEncoderOld(ICodePointFilter filter)
     : this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
 }
Esempio n. 13
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public JavaScriptStringEncoderOld(ICodePointFilter filter)
     : this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
 }
 /// <summary>
 /// Wraps the provided filter as a CodePointFilter, avoiding the clone if possible.
 /// </summary>
 internal static CodePointFilter Wrap(ICodePointFilter filter)
 {
     return (filter as CodePointFilter) ?? new CodePointFilter(filter);
 }
        /// <summary>
        /// Allows all characters specified by <paramref name="filter"/> through the filter.
        /// </summary>
        /// <returns>
        /// The 'this' instance.
        /// </returns>
        public CodePointFilter AllowFilter(ICodePointFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            foreach (var allowedCodePoint in filter.GetAllowedCodePoints())
            {
                // If the code point can't be represented as a BMP character, skip it.
                char codePointAsChar = (char)allowedCodePoint;
                if (allowedCodePoint == codePointAsChar)
                {
                    _allowedCharsBitmap.AllowCharacter(codePointAsChar);
                }
            }
            return this;
        }
Esempio n. 16
0
 /// <summary>
 /// Wraps the provided filter as a CodePointFilter, avoiding the clone if possible.
 /// </summary>
 internal static CodePointFilter Wrap(ICodePointFilter filter)
 {
     return((filter as CodePointFilter) ?? new CodePointFilter(filter));
 }
Esempio n. 17
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public JavaScriptStringEncoderOld(ICodePointFilter filter)
     : this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Instantiates an encoder using a custom code point filter. Any character not in the
 /// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
 /// method will be escaped.
 /// </summary>
 public UrlEncoder([NotNull] ICodePointFilter filter)
     : this(new UrlUnicodeEncoder(CodePointFilter.Wrap(filter)))
 {
 }