package com.laytonsmith.PureUtilities.Common;
/**
*
*/
public class HTMLUtils {
/**
* Given a raw string, escapes html special characters. For instance, turning
* < into <
* <!-- for those reading the javadoc directly in code, that's: -->
* <!-- < into < -->
* @param raw
* @return
*/
public static String escapeHTML(String raw){
return raw.replace("&", "&")
.replace("<", "<")
.replace(">", ">")
.replace("\"", """)
.replace("'", "'");
}
/**
* Given escaped html characters, unescapes them. For instance, turning
* < into <
* <!-- for those reading the javadoc directly in code, that's: -->
* <!-- < into < -->
* @param html
* @return
*/
public static String unescapeHTML(String html){
return html.replace("'", "'")
.replace(""", "\"")
.replace(">", ">")
.replace("<", "<")
.replace("&", "&");
}
}