Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import com.google.common.escape.Escapers;

public class HtmlEscaper extends Escaper {
private static final HtmlEscaper SINGLETON = new HtmlEscaper();

// Based on the observation of the generated java files, we escape the following
// five characters by html escaper. We do not directly use guava HtmlEscapers here because
// it only escapes`<>&\"'` as specified by HTML 4.01.
private static final Escaper escaper =
private static final Escaper charEscaper =
Escapers.builder()
.addEscape('<', "&lt;")
.addEscape('>', "&gt;")
Expand All @@ -34,10 +36,10 @@ private HtmlEscaper() {}

@Override
public String escape(String sourceString) {
return escaper.escape(sourceString);
return charEscaper.escape(sourceString);
}

public static String escaper(String source) {
return new HtmlEscaper().escape(source);
return SINGLETON.escape(source);
}
}