diff --git a/app/uk/gov/hmrc/gform/summary/SummaryRenderingService.scala b/app/uk/gov/hmrc/gform/summary/SummaryRenderingService.scala
index 0cb25b1d7..5386df135 100644
--- a/app/uk/gov/hmrc/gform/summary/SummaryRenderingService.scala
+++ b/app/uk/gov/hmrc/gform/summary/SummaryRenderingService.scala
@@ -807,10 +807,10 @@ object SummaryRenderingService {
)(implicit messages: Messages, l: LangADT, sse: SmartStringEvaluator) =
summaryDataList.map {
case pageData: PageData => summaryPage(pageData)
- case AddToListData(title, summary, pageGroups, _) =>
+ case AddToListData(title, summary, pageGroups, id) =>
val summaryValues = summary.values.zipWithIndex.map { case (v, idx) => (idx + 1) -> v }
val addToListSummaryPage = addToListSummary(summaryValues)
- addToList(title, Some(summary.title), addToListSummaryPage, pageGroups)
+ addToList(id, title, Some(summary.title), addToListSummaryPage, pageGroups)
}
def renderPageField(field: PageField): XmlFormat.Appendable = field match {
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/PdfHelper.scala b/app/uk/gov/hmrc/gform/views/summary/pdf/PdfHelper.scala
index 715bff211..7f15758cc 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/PdfHelper.scala
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/PdfHelper.scala
@@ -21,16 +21,27 @@ import play.twirl.api.{ Html, XmlFormat }
import uk.gov.hmrc.gform.views.xml.summary.pdf.simpleField
object PdfHelper {
+ private val replacements =
+ Map('<' -> "<", '>' -> ">", '&' -> "&", ']' -> "]", '\'' -> "'", '"' -> """)
+
def renderHtml(value: String): XmlFormat.Appendable = {
val newLineDelimiters = List("
", "\n\n")
val maybeDelimiter = newLineDelimiters.find(value.contains)
val lines = maybeDelimiter match {
case Some(delimiter) => value.split(delimiter)
- case None => return XmlFormat.raw(StringEscapeUtils.unescapeXml(value))
+ case None => return XmlFormat.raw(sanitizeContent(value))
}
- simpleField(lines.map(StringEscapeUtils.unescapeXml).map(Html(_)).toList)
+ simpleField(lines.map(sanitizeContent).map(Html(_)).toList)
}
+ def sanitizeContent(content: String): String =
+ StringEscapeUtils.unescapeXml(content.foldLeft("") { (acc, char) =>
+ replacements.getOrElse(char, char.toString) match {
+ case replacement: String => acc + replacement
+ case _ => acc
+ }
+ })
+
}
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/addToList.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/addToList.scala.xml
index 72817db1e..b0cb02beb 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/addToList.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/addToList.scala.xml
@@ -1,10 +1,12 @@
@import play.twirl.api.XmlFormat
@import uk.gov.hmrc.gform.pdf.model.PDFModel.{ AddToListSummary, AddToListPageGroup }
@import uk.gov.hmrc.gform.summary.SummaryRenderingService
+@import uk.gov.hmrc.gform.views.summary.pdf.PdfHelper
-@(title: String, summaryTitle: Option[String], summaryValue: XmlFormat.Appendable, pageGroups: List[AddToListPageGroup])(implicit messages: Messages, l:LangADT, sse: SmartStringEvaluator)
+@(id: String, title: String, summaryTitle: Option[String], summaryValue: XmlFormat.Appendable, pageGroups: List[AddToListPageGroup])(implicit messages: Messages, l:LangADT, sse: SmartStringEvaluator)
-
@pageGroups.map { pageGroup =>
-
@if(page.title.isDefined){
-
- @page.title.map(t => unescapeXml(t))
+ @page.title.map(t => PdfHelper.sanitizeContent(t))
} else {
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummary.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummary.scala.xml
index f3cf06393..20288b24d 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummary.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummary.scala.xml
@@ -14,16 +14,12 @@
font-weight="bold"
font-size="11pt"
line-height="11pt">
-
-
- @value._1 -
-
-
+ @value._1.
-
- @{SummaryRenderingService.renderAddToListSummaryItemBody(value._2)}
+
+ @{SummaryRenderingService.renderAddToListSummaryItemBody(value._2)}
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummaryItemBody.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummaryItemBody.scala.xml
index 051fd0219..7c4710424 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummaryItemBody.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/addToListSummaryItemBody.scala.xml
@@ -1,18 +1,13 @@
@import play.twirl.api.XmlFormat
@(boldText: String, normalText: XmlFormat.Appendable)
-
-
- @boldText
-
- @normalText
-
+@boldText
+ @normalText
-
+
\ No newline at end of file
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/bookmarkTree.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/bookmarkTree.scala.xml
new file mode 100644
index 000000000..f3e4a679e
--- /dev/null
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/bookmarkTree.scala.xml
@@ -0,0 +1,33 @@
+@import uk.gov.hmrc.gform.pdf.model.PDFModel._
+
+@(formName: Option[String], summaryDatas: List[SummaryData])
+
+
+ @formName.map{ title =>
+ @title
+ }
+ @for(summaryData <- summaryDatas) {
+ @summaryData match {
+ case p: PageData => {
+ @for(title <- p.title) {
+
+ @{title}
+
+ }
+ }
+ case AddToListData(title, _, pageGroups, id) => {
+ @if(title.nonEmpty) {
+
+ @{title}
+ @for(pageGroup <- pageGroups) {
+
+ @{title}
+
+ }
+
+ }
+ }
+ }
+ }
+
+
\ No newline at end of file
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/choiceField.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/choiceField.scala.xml
index 0a649d033..2495335b1 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/choiceField.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/choiceField.scala.xml
@@ -1,3 +1,5 @@
+@import uk.gov.hmrc.gform.views.summary.pdf.PdfHelper
+
@(values: List[Html])
@if(values.size > 1) {
@@ -23,7 +25,7 @@
font-family="arial"
font-weight="normal"
line-height="11pt">
- @unescapeXml(value.body)
+ @PdfHelper.sanitizeContent(value.body)
@@ -33,7 +35,7 @@
} else {
@values.map{ value =>
- @unescapeXml(value.body)
+ @PdfHelper.sanitizeContent(value.body)
}
}
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/revealingChoiceField.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/revealingChoiceField.scala.xml
index a9e375c68..597918b1e 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/revealingChoiceField.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/revealingChoiceField.scala.xml
@@ -1,3 +1,5 @@
+@import uk.gov.hmrc.gform.views.summary.pdf.PdfHelper
+
@(values: List[Html])
@if(values.size > 1) {
@@ -24,7 +26,7 @@
font-family="arial"
font-weight="normal"
line-height="11pt">
- @unescapeXml(value.body)
+ @PdfHelper.sanitizeContent(value.body)
@@ -34,7 +36,7 @@
} else {
@values.map{ value =>
- @unescapeXml(value.body)
+ @PdfHelper.sanitizeContent(value.body)
}
}
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/submissionDetailsListItem.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/submissionDetailsListItem.scala.xml
index 6d179896c..4c29ee435 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/submissionDetailsListItem.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/submissionDetailsListItem.scala.xml
@@ -1,3 +1,5 @@
+@import uk.gov.hmrc.gform.views.summary.pdf.PdfHelper
+
@(label: String, value: String)
- @{unescapeXml(label)}
+ @{PdfHelper.sanitizeContent(label)}
- @{unescapeXml(value)}
+ @{PdfHelper.sanitizeContent(value)}
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/summary.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/summary.scala.xml
index cb30acb19..fdf570081 100644
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/summary.scala.xml
+++ b/app/uk/gov/hmrc/gform/views/summary/pdf/summary.scala.xml
@@ -58,6 +58,8 @@
+ @bookmarkTree(maybeFormName, summaryDataList)
+
@maybeFormName.map{ formName =>
-
}
-
+
@if(pageData.title.isDefined){
- @pageData.title.map(t => unescapeXml(t))
+ @pageData.title.map(t => PdfHelper.sanitizeContent(t))
} else {
diff --git a/app/uk/gov/hmrc/gform/views/summary/pdf/unescapeXml.scala.xml b/app/uk/gov/hmrc/gform/views/summary/pdf/unescapeXml.scala.xml
deleted file mode 100644
index e908940a4..000000000
--- a/app/uk/gov/hmrc/gform/views/summary/pdf/unescapeXml.scala.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-@import org.apache.commons.text.StringEscapeUtils
-
-@(value: String)
-@{StringEscapeUtils.unescapeXml(value)}