mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 08:22:15 +00:00
Escape HTML provided in form - issue #148
This commit is contained in:
@@ -11,6 +11,10 @@ function nl2br (str, is_xhtml) {
|
|||||||
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeHtml (str) {
|
||||||
|
return $('<div/>').text(str).html();
|
||||||
|
}
|
||||||
|
|
||||||
function updatePrices() {
|
function updatePrices() {
|
||||||
// individual rows
|
// individual rows
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
@@ -101,8 +105,8 @@ $('body').on('submit', '#item-form', function (e) {
|
|||||||
}
|
}
|
||||||
// update the table
|
// update the table
|
||||||
$row = $('#item-' + pk);
|
$row = $('#item-' + pk);
|
||||||
$row.find('.name').html(fields.name);
|
$row.find('.name').html(escapeHtml(fields.name));
|
||||||
$row.find('.description').html(nl2br(fields.description));
|
$row.find('.description').html(nl2br(escapeHtml(fields.description)));
|
||||||
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
|
||||||
$row.find('.quantity').html(fields.quantity);
|
$row.find('.quantity').html(fields.quantity);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user