Java Code Examples for org.jsoup.safety.Cleaner#isValid()

The following examples show how to use org.jsoup.safety.Cleaner#isValid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jsoup.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 Test if the input HTML has only tags and attributes allowed by the Whitelist. Useful for form validation. The input HTML should
 still be run through the cleaner to set up enforced attributes, and to tidy the output.
 @param bodyHtml HTML to test
 @param whitelist whitelist to test against
 @return true if no tags or attributes were removed; false otherwise
 @see #clean(String, org.jsoup.safety.Whitelist) 
 */
public static boolean isValid(String bodyHtml, Whitelist whitelist) {
    Document dirty = parseBodyFragment(bodyHtml, "");
    Cleaner cleaner = new Cleaner(whitelist);
    return cleaner.isValid(dirty);
}
 
Example 2
Source File: Jsoup.java    From jsoup-learning with MIT License 2 votes vote down vote up
/**
 Test if the input HTML has only tags and attributes allowed by the Whitelist. Useful for form validation. The input HTML should
 still be run through the cleaner to set up enforced attributes, and to tidy the output.
 @param bodyHtml HTML to test
 @param whitelist whitelist to test against
 @return true if no tags or attributes were removed; false otherwise
 @see #clean(String, org.jsoup.safety.Whitelist) 
 */
public static boolean isValid(String bodyHtml, Whitelist whitelist) {
    Document dirty = parseBodyFragment(bodyHtml, "");
    Cleaner cleaner = new Cleaner(whitelist);
    return cleaner.isValid(dirty);
}