Closed kkononov closed 4 years ago
It turned out to be bloody Kotlin JS. The following test:
private val replacements: Map<Char, String> = mapOf(
'<' to "<",
'>' to ">"
)
println("${replacements[60.toChar()]} ${60.toChar().let {replacements[it]}} ${60.toChar()?.let {replacements[it]}}")
prints < < null
.
I'll rewrite code in another way.
Fixed in 55dcc1b0ff57378891d9fc8ef718d09a414e1c65, JS-only problem.
Available in kotlin-js-clean
branch, 0.2.0-pre-7 is published as well
With input containing
<
and>
(in the escaped form), we end up having incorrect HTML.Example input:
<wrongTag>
Output HTML:<wrongTag>
Not sure, but the same problem may be with
&
(in the escaped form)The reason is in what
EntityConverter#replaceEntities(text: CharSequence, processEntities: Boolean, processEscapes: Boolean)
does when called withtrue
values of arguments.