/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.harvard.iq.dataverse.util;

import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;

/**
 * Wrapper for Jsoup clean
 * 
 * @author rmp553
 */
public class MarkupChecker {
    
    
    
    /**
     * Wrapper around Jsoup clean method with the basic White list
     *   http://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer
     * @param unsafe
     * @return 
     */
    public static String sanitizeBasicHTML(String unsafe){
        
        if (unsafe == null){
            return null;
        }
        // basic includes: a, b, blockquote, br, cite, code, dd, dl, dt, em, i, li, ol, p, pre, q, small, span, strike, strong, sub, sup, u, ul
        Whitelist wl = Whitelist.basic().addTags("img", "h1", "h2", "h3", "kbd", "hr", "s", "del");       
        
        return Jsoup.clean(unsafe, wl);
        
    }

    /**
     * Strip all HTMl tags
     * 
     * http://jsoup.org/apidocs/org/jsoup/safety/Whitelist.html#none%28%29
     * 
     * @param unsafe
     * @return 
     */
    public static String stripAllTags(String unsafe){
        
        if (unsafe == null){
            return null;
        }        
        
        return Jsoup.clean(unsafe, Whitelist.none());
        
    }

}

@@ -852,16 +852,18 @@
         
+//
 Whitelis
@@ -947,30 +947,275 @@
 del%22);  
+%0A%0A
      
-%0A        
+   Whitelist wl = Whitelist.basicWithImages().addTags( %22h1%22, %22h2%22, %22h3%22, %22kbd%22, %22hr%22, %22s%22, %22del%22,%22map%22,%22area%22).addAttributes(%22img%22, %22usemap%22)%0A                .addAttributes(%22map%22, %22name%22).addAttributes(%22area%22, %22shape%22,%22coords%22,%22href%22,%22title%22,%22alt%22);  %0A
 %0A       

Add attributes for maps to html whitelist