Skip to content

Commit

Permalink
Sanitise question text
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonf committed Mar 18, 2024
1 parent 7a0921a commit 1ebe026
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/kotlin/internal/svs/VariablePageContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ data class VariablePageContent(
private fun Element.asQuestion(): Question {
val spanAttribute = "data-en"
return Question(
period = select("td:eq(0) span[$spanAttribute]").attr(spanAttribute),
instrument = select("td:eq(1) span[$spanAttribute]").attr(spanAttribute),
text = select("td:eq(2) span[$spanAttribute]").attr(spanAttribute),
period = select("td:eq(0) span[$spanAttribute]").attr(spanAttribute).sanitise(),
instrument = select("td:eq(1) span[$spanAttribute]").attr(spanAttribute).sanitise(),
text = select("td:eq(2) span[$spanAttribute]").attr(spanAttribute).sanitise(),
referenceUrl = URL(PANEL_DATA_SITE_DOMAIN + select("td:eq(2) a").attr("href"))
)
}

private fun String.sanitise() = lines().joinToString().trim()
}

0 comments on commit 1ebe026

Please sign in to comment.