Skip to content

Commit 1b73d00

Browse files
committed
encode html entities
1 parent aa7e9d5 commit 1b73d00

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ name := "scala-release-note-generator"
33
scalaVersion := "2.10.0-RC3"
44

55
libraryDependencies += "org.pegdown" % "pegdown" % "1.2.0"
6+
7+
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.1"

src/main/scala/GitInfo.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object GitHelper {
3434
issues map (si => """<a href="https://issues.scala-lang.org/browse/%s">%s</a>""" format (si, si)) mkString ", "
3535
}
3636

37+
def htmlEncode(s: String) = org.apache.commons.lang3.StringEscapeUtils.escapeHtml4(s)
3738
}
3839

3940
class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: String) {
@@ -66,7 +67,7 @@ class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: Str
6667
| <thead><tr><th>#</th><th align="left">Author</th></tr></thead>
6768
|<tbody>""".stripMargin
6869
for((author, count) <- authors)
69-
sb append s"""<tr><td align="right">${count} &nbsp;</td><td>${author}</td></tr>"""
70+
sb append s"""<tr><td align="right">${count} &nbsp;</td><td>${htmlEncode(author)}</td></tr>"""
7071
sb append """</tbody></table>"""
7172
sb.toString
7273
}
@@ -79,7 +80,7 @@ class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: Str
7980
<thead><tr><th>sha</th><th align="left">Title</th></tr></thead>
8081
<tbody>"""
8182
for(commit <- commits)
82-
sb append s"""<tr><td align="right">${commitShaLink(commit.sha)}&nbsp;</td><td>${commit.header}</td></tr>"""
83+
sb append s"""<tr><td align="right">${commitShaLink(commit.sha)}&nbsp;</td><td>${htmlEncode(commit.header)}</td></tr>"""
8384
sb append """</tbody>
8485
</table>"""
8586
sb.toString
@@ -93,7 +94,7 @@ class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: Str
9394
<thead><tr><th>Issue(s)</th><th>Commit</th><th>Message</th></tr></thead>
9495
<tbody>""")
9596
for(commit <- fixCommits)
96-
sb append s"""<tr><td>${fixLinks(commit)}&nbsp;</td><td>${commitShaLink(commit.sha)}&nbsp;</td><td>${commit.header}</td></tr>"""
97+
sb append s"""<tr><td>${fixLinks(commit)}&nbsp;</td><td>${commitShaLink(commit.sha)}&nbsp;</td><td>${htmlEncode(commit.header)}</td></tr>"""
9798
sb append """</tbody>
9899
</table>"""
99100
sb append blankLine()

0 commit comments

Comments
 (0)