scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

HTML-like code in code blocks of Scaladoc should not be rendered as HTML #12022

Closed Atry closed 2 years ago

Atry commented 4 years ago

reproduction steps

using Scala 2.13.2,

/** 
  * {{{
  * @html
  * val myDiv = <div class="my-class" tabindex="42"></div>
  * myDiv.value.nodeName should be("DIV")
  * myDiv.value.className should be("my-class")
  * myDiv.value.tabIndex should be(42)
  * }}}
  */

problem

It rendered as:

@html
val myDiv =

myDiv.value.nodeName should be("DIV")
myDiv.value.className should be("my-class")
myDiv.value.tabIndex should be(42)

This issue is created because it's similar but different from #11424

danicheg commented 2 years ago

I guess this behavior is expected. Since the div tag is marked as dangerous and filtered out by intent. See https://github.com/scala/scala/blob/2.13.x/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala#L128-L129. If one will try out another tag, like <foo>, scaladoc from your snippet will be generated fine:

/**
 * {{{
 * @html
 * val myDiv = <foo class="my-class" tabindex="42"></foo>
 * myDiv.value.nodeName should be("DIV")
 * myDiv.value.className should be("my-class")
 * myDiv.value.tabIndex should be(42)
 * }}}
 */

That seems reasonable to me and works as designed at least. cc @SethTisue 🙇🏻‍♂️