src/it/finsiel/siged/util/HtmlParser.java
public static String validateHTMLString(String input) {
        StringBuffer output = new StringBuffer(input);
        int index = 0;

        String lowerCaseInput = input.toLowerCase();

        // Check for missing <html> tag
        if (lowerCaseInput.indexOf("<html>") == -1) {
            if (lowerCaseInput.indexOf("<!doctype") != -1) {
                index = lowerCaseInput.indexOf("\n", lowerCaseInput
                        .indexOf("<!doctype")) + 1;
            }

            output.insert(index, "<html>");
        }

        // Check for missing </html> tag
        if (lowerCaseInput.indexOf("</html>") == -1) {
            output.append("</html>");
        }

        // remove characters after </html> tag
        index = lowerCaseInput.indexOf("</html>");

        if (lowerCaseInput.length() >= (index + 7)) {
            lowerCaseInput = lowerCaseInput.substring(0, index + 7);
        }

        return output.toString();
    }
/**
     * Tries to fix broken html-strings by inserting html start- and end tags if
     * missing, and by removing content after the html end tag.
     * 
     * @param input
     *            html content to be validated
     * @return content with extra tags inserted if necessary
     */
Tries to fix broken html-strings by inserting html start- and end tags if
missing, and by removing content after the html end tag.

@param input
html content to be validated
@return content with extra tags inserted if necessary
Tries to fix broken html - strings by inserting html start - and end tags if missing and by removing content after the html end tag . @param input html content to be validated @return content with extra tags inserted if necessary
public static String validateHTMLString(String input) {
        StringBuffer output = new StringBuffer(input);
        int index = 0;
        String lowerCaseInput = input.toLowerCase();
        if (lowerCaseInput.indexOf("<html>") == -1) {
            if (lowerCaseInput.indexOf("<!doctype") != -1) {
                index = lowerCaseInput.indexOf("\n", lowerCaseInput
                        .indexOf("<!doctype")) + 1;
            }
            output.insert(index, "<html>");
        }
        if (lowerCaseInput.indexOf("</html>") == -1) {
            output.append("</html>");
        }
        index = lowerCaseInput.indexOf("</html>");
        if (lowerCaseInput.length() >= (index + 7)) {
            lowerCaseInput = lowerCaseInput.substring(0, index + 7);
        }
        return output.toString();
    }
public static String validateHTMLString ( String input ) { StringBuffer output = new StringBuffer ( input ) ; int index = 0 ; String lowerCaseInput = input . toLowerCase ( ) ; if ( lowerCaseInput . indexOf ( "<html>" ) == - 1 ) { if ( lowerCaseInput . indexOf ( "<!doctype" ) != - 1 ) { index = lowerCaseInput . indexOf ( "\n" , lowerCaseInput . indexOf ( "<!doctype" ) ) + 1 ; } output . insert ( index , "<html>" ) ; } if ( lowerCaseInput . indexOf ( "</html>" ) == - 1 ) { output . append ( "</html>" ) ; } index = lowerCaseInput . indexOf ( "</html>" ) ; if ( lowerCaseInput . length ( ) >= ( index + 7 ) ) { lowerCaseInput = lowerCaseInput . substring ( 0 , index + 7 ) ; } return output . toString ( ) ; }
Tries to fix broken html-strings by inserting html start- and end tags if
 missing, and by removing content after the html end tag.
Tries to fix broken html - strings by inserting html start - and end tags if missing and by removing content after the html end tag .
// Check for missing <html> tag // Check for missing </html> tag // remove characters after </html> tag