fuck replaceAllIn api design (fixes #6632)

This commit is contained in:
Niklas Fiekas 2020-05-15 11:09:20 +02:00
parent 11b9a81b6f
commit bde8938004
2 changed files with 6 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package views.html.mod
import scala.util.matching.Regex
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
@ -25,7 +27,7 @@ object inquiry {
case "swiss" => routes.Swiss.show(id)
case _ => s"/${m.group(1)}/$id"
}
s"$netBaseUrl$path ${m.group(3)}"
Regex.quoteReplacement(s"$netBaseUrl$path ${m.group(3)}")
}
)
)

View file

@ -8,6 +8,7 @@ import com.vladsch.flexmark.parser.Parser
import com.vladsch.flexmark.util.data.MutableDataSet
import java.util.Arrays
import scala.concurrent.duration._
import scala.util.matching.Regex
object BlogTransform {
@ -21,7 +22,7 @@ object BlogTransform {
private type Text = String
private type Html = String
private val Regex = """<pre>markdown(.+)</pre>""".r
private val PreRegex = """<pre>markdown(.+)</pre>""".r
private val options = new MutableDataSet()
options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()))
@ -35,6 +36,6 @@ object BlogTransform {
.maximumSize(32)
.build((text: Text) => renderer.render(parser.parse(text.replace("<br>", "\n"))))
def apply(html: Html): Html = Regex.replaceAllIn(html, m => cache get m.group(1))
def apply(html: Html): Html = PreRegex.replaceAllIn(html, m => Regex.quoteReplacement(cache get m.group(1)))
}
}