Replace owasp java encoder with faster implementation #227
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Benchmarks as in #225 have shown that OWASP Java Encoder is slower than expected for output escaping. In order to use the faster methods of OWASP encoder, all template outputs had to provide an instance of the rather ancient and clumsy
Writer
interface, that really should not be part of the public API ofTemplateOutput
.This PR replaces the four methods we currently use from the OWASP Java Encoder project by optimized methods that work directly on a
TemplateOutput
:org.owasp.encoder.Encode.forHtmlContent
->gg.jte.html.escape.Escape.htmlContent
org.owasp.encoder.Encode.forHtmlAttribute
->gg.jte.html.escape.Escape.htmlAttribute
org.owasp.encoder.Encode.forJavaScriptBlock
->gg.jte.html.escape.Escape.javaScriptBlock
org.owasp.encoder.Encode.forJavaScriptAttribute
->gg.jte.html.escape.Escape.javaScriptAttribute
All methods should behave exactly like their OWASP counterparts.
After this patch is merged, jte will be free from external dependencies.