Add ability to pass CharSequence instead of forcing String for context variable.

java.lang.String is immutable and cannot be overwritten by user.
When passing sensitive data as context variable String remains in memory until GC removes it.
CharSequence allows user to provide his own implementation and overwrite data as needed.
This commit is contained in:
Ralfs Gūtmanis
2023-09-18 14:04:46 +03:00
parent 5b0fa29a74
commit d1d72031f2
4 changed files with 35 additions and 8 deletions
@@ -384,9 +384,9 @@ public class Template {
abstract void visit (Mustache.Visitor visitor);
protected static void write (Writer out, String data) {
protected static void write (Writer out, CharSequence data) {
try {
out.write(data);
out.append(data);
} catch (IOException ioe) {
throw new MustacheException(ioe);
}