mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-01-03 06:09:58 +01:00
(refs #751)Fix issue reference in verbatim node
This commit is contained in:
@@ -2,7 +2,6 @@ package gitbucket.core.view
|
||||
|
||||
import gitbucket.core.controller.Context
|
||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.Implicits
|
||||
import gitbucket.core.util.Implicits.RichString
|
||||
|
||||
trait LinkConverter { self: RequestCache =>
|
||||
@@ -11,10 +10,12 @@ trait LinkConverter { self: RequestCache =>
|
||||
* Converts issue id, username and commit id to link.
|
||||
*/
|
||||
protected def convertRefsLinks(value: String, repository: RepositoryService.RepositoryInfo,
|
||||
issueIdPrefix: String = "#")(implicit context: Context): String = {
|
||||
value
|
||||
// escape HTML tags
|
||||
.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """)
|
||||
issueIdPrefix: String = "#", escapeHtml: Boolean = true)(implicit context: Context): String = {
|
||||
|
||||
// escape HTML tags
|
||||
val escaped = if(escapeHtml) value.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) else value
|
||||
|
||||
escaped
|
||||
// convert issue id to link
|
||||
.replaceBy(("(?<=(^|\\W))" + issueIdPrefix + "([0-9]+)(?=(\\W|$))").r){ m =>
|
||||
getIssue(repository.owner, repository.name, m.group(2)) match {
|
||||
|
||||
@@ -177,6 +177,18 @@ class GitBucketHtmlSerializer(
|
||||
}
|
||||
}
|
||||
|
||||
override def visit(node: VerbatimNode) {
|
||||
val printer = new Printer()
|
||||
val serializer = verbatimSerializers.get(VerbatimSerializer.DEFAULT)
|
||||
serializer.serialize(node, printer)
|
||||
val html = printer.getString
|
||||
|
||||
// convert commit id and username to link.
|
||||
val t = if(enableRefsLink) convertRefsLinks(html, repository, "issue:", escapeHtml = false) else html
|
||||
|
||||
this.printer.print(t)
|
||||
}
|
||||
|
||||
override def visit(node: BulletListNode): Unit = {
|
||||
if (printChildrenToString(node).contains("""class="task-list-item-checkbox" """)) {
|
||||
printer.println().print("""<ul class="task-list">""").indent(+2)
|
||||
|
||||
Reference in New Issue
Block a user