Search in sources :

Example 11 with Document

use of com.smartandroid.sa.tag.nodes.Document in project SmartAndroidSource by jaychou2012.

the class Cleaner method clean.

/**
	 * Creates a new, clean document, from the original dirty document,
	 * containing only elements allowed by the whitelist. The original document
	 * is not modified. Only elements from the dirt document's <code>body</code>
	 * are used.
	 * 
	 * @param dirtyDocument
	 *            Untrusted base document to clean.
	 * @return cleaned document.
	 */
public Document clean(Document dirtyDocument) {
    Validate.notNull(dirtyDocument);
    Document clean = Document.createShell(dirtyDocument.baseUri());
    if (// frameset documents won't have a
    dirtyDocument.body() != null)
        // body. the clean doc will have
        // empty body.
        copySafeNodes(dirtyDocument.body(), clean.body());
    return clean;
}
Also used : Document(com.smartandroid.sa.tag.nodes.Document)

Aggregations

Document (com.smartandroid.sa.tag.nodes.Document)11 Element (com.smartandroid.sa.tag.nodes.Element)4 Cleaner (com.smartandroid.sa.tag.safety.Cleaner)3 Node (com.smartandroid.sa.tag.nodes.Node)1 Elements (com.smartandroid.sa.tag.select.Elements)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1