diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 43410107c81..9403bdf3401 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -1,4 +1,5 @@ ### Improvements +### Bug Fixes -### Bug Fixes \ No newline at end of file +- Fix HTML escaping after `{@literal ...}` blocks in Javadocs \ No newline at end of file diff --git a/pkg/codegen/java/utilities.go b/pkg/codegen/java/utilities.go index 00d8024f9bf..f7062c437aa 100644 --- a/pkg/codegen/java/utilities.go +++ b/pkg/codegen/java/utilities.go @@ -148,7 +148,7 @@ func (w *plainJavadocWriter) WriteRune(r rune) { w.b.WriteRune('@') } else { w.b.WriteRune('}') - w.b.WriteRune(r) + w.b.WriteString(html.EscapeString(string(r))) w.state = plainJavadocText } } diff --git a/pkg/codegen/java/utilities_test.go b/pkg/codegen/java/utilities_test.go index 5586ebb7872..5552dc67023 100644 --- a/pkg/codegen/java/utilities_test.go +++ b/pkg/codegen/java/utilities_test.go @@ -96,10 +96,12 @@ func TestFormatForeignComments(t *testing.T) { - @Foo @ bar - Foo @ bar - Foo bar @@ +- Foo @ works? `, expected: autogold.Expect(` * - {@literal @}Foo {@literal @} bar * - Foo {@literal @} bar * - Foo bar {@literal @@} + * - Foo {@literal @}<this> works? * `), }, {