Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. /****** pull out style tag from html *****/
  2. Pattern p = Pattern.compile("<style>([\s\S]+?)</style>");
  3. Matcher m = p.matcher(validHTML);
  4.  
  5. // if we find a match, get the group
  6. if (m.find()) {
  7.  
  8. // get the matching group
  9. codeGroup = m.group(1);
  10. }
  11. /****** block for checking all css for validity *****/
  12.  
  13. InternalPolicy policy = null;
  14. try {
  15. policy = (InternalPolicy) InternalPolicy.getInstance("antisamy-ebay.xml");
  16. } catch (PolicyException e) {
  17. e.printStackTrace();
  18. }
  19. ResourceBundle messages = ResourceBundle.getBundle("AntiSamy", Locale.getDefault());
  20.  
  21. CssScanner scanner = new CssScanner(policy, messages);
  22. CleanResults results = scanner.scanStyleSheet(codeGroup, Integer.MAX_VALUE);
  23. validCSS = results.getCleanHTML().toString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement