Skip to content

Commit

Permalink
Fix escaping on pagador and instruction fields
Browse files Browse the repository at this point in the history
  • Loading branch information
derekstavis committed Apr 25, 2018
1 parent 320bf17 commit 0f20e48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/formatters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const escapeXML = require('ejs').escapeXML

exports.capitalize = function (string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
Expand Down Expand Up @@ -94,5 +96,5 @@ exports.removeTrailingZeros = function (string) {
}

exports.htmlString = function (str) {
return str ? str.replace(/\n/g, '<br/>') : str
return str ? escapeXML(str).replace(/\n/g, '<br/>') : str
}
8 changes: 4 additions & 4 deletions test/e2e/boleto-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ module.exports = (bankLogo, bankNumber, linhaDigitavel, barcode, bmpBarcode) =>
<td class="w659">Pagador</td>
</tr>
<tr class="cp h12">
<td>Nome do pagador<br/>CPF: 000.000.000-00</td>
<td>Nome do pagador<br/>CPF: 000.000.000-00&lt;script&gt;alert(1)&lt;/script&gt;</td>
</tr>
<tr class="cp h12 rBb">
<td></td>
Expand All @@ -234,7 +234,7 @@ module.exports = (bankLogo, bankNumber, linhaDigitavel, barcode, bmpBarcode) =>
<td class="w180 Ar">Autenticação mecânica</td>
</tr>
<tr class="cpN h12">
<td class="pL6">Sr. Caixa, aceitar o pagamento e não cobrar juros após o vencimento.</td>
<td class="pL6">Sr. Caixa, aceitar o pagamento e não cobrar juros após o vencimento.&lt;script&gt;alert(1)&lt;/script&gt;</td>
<td class="pL6 Ar"></td>
</tr>
</table><table class="ctN w666">
Expand Down Expand Up @@ -308,7 +308,7 @@ module.exports = (bankLogo, bankNumber, linhaDigitavel, barcode, bmpBarcode) =>
<tr class="rc6">
<td class="w478">
<div class="ctN pL10">Instruções (Texto de responsabilidade do beneficiário)</div>
<div class="cpN pL10">Sr. Caixa, aceitar o pagamento e não cobrar juros após o vencimento.</div>
<div class="cpN pL10">Sr. Caixa, aceitar o pagamento e não cobrar juros após o vencimento.&lt;script&gt;alert(1)&lt;/script&gt;</div>
</td>
<td class="w186">
<div class="t">(-) Desconto / Abatimentos</div>
Expand All @@ -328,7 +328,7 @@ module.exports = (bankLogo, bankNumber, linhaDigitavel, barcode, bmpBarcode) =>
<td class="w659">Pagador</td>
</tr>
<tr class="cp h12">
<td class="At">Nome do pagador<br/>CPF: 000.000.000-00</td>
<td class="At">Nome do pagador<br/>CPF: 000.000.000-00&lt;script&gt;alert(1)&lt;/script&gt;</td>
</tr>
</table><table class="w666">
<tr class="rBb">
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/boleto-render.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f20e48

Please sign in to comment.