Exemplo n.º 1
0
        /// <summary> The meat and potatoes. The <code>scan()</code> family of methods are the only methods the outside world should
        /// be calling to invoke AntiSamy.
        /// 
        /// </summary>
        /// <param name="taintedHTML">Untrusted HTML which may contain malicious code.
        /// </param>
        /// <param name="inputEncoding">The encoding of the input.
        /// </param>
        /// <param name="outputEncoding">The encoding that the output should be in.
        /// </param>
        /// <returns> A <code>CleanResults</code> object which contains information about the scan (including the results).
        /// </returns>
        /// <throws>  <code>ScanException</code> When there is a problem encountered while scanning the HTML. </throws>
        /// <throws>  <code>PolicyException</code> When there is a problem reading the policy file. </throws>

        public virtual CleanResults scan(string taintedHTML)
        {
            Policy policy = null;

            /*
            * Get or reload the policy document (antisamy.xml). We'll need to pass that to the
            * scanner so it knows what to look for.
            */

            policy = Policy.getInstance();

            AntiSamyDOMScanner antiSamy = new AntiSamyDOMScanner(policy);

            /*
            * Go get 'em!
            */
            return antiSamy.scan(taintedHTML, inputEncoding, outputEncoding);
        }
Exemplo n.º 2
0
        /// <summary> This method wraps <code>scan()</code> using the policy File object passed in.</summary>
        public virtual CleanResults scan(string taintedHTML, Policy policy)
        {

            AntiSamyDOMScanner antiSamy = new AntiSamyDOMScanner(policy);

            /*
            * Go get 'em!
            */

            return antiSamy.scan(taintedHTML, inputEncoding, outputEncoding);
        }