encode uri and html

This commit is contained in:
Eric A. Miller
2014-05-27 23:15:12 -04:00
parent 039e43f72e
commit efe17e96bb
6 changed files with 192 additions and 167 deletions

View File

@@ -15,18 +15,26 @@ $(document).ready(function() {
"deferRender": true,
"data": [% results %],
"columns": [{
data: 'ip',
render: function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + data + '">' + (row.dns || row.name || row.ip) + '</a>';
"data": 'ip',
"render": function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '">' + he.encode(row.dns || row.name || row.ip) + '</a>';
}
}, {
data: 'alias'
"data": 'alias',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
data: 'contact'
"data": 'contact',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
data: 'location'
"data": 'location',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}
]
});
});</script>

View File

@@ -14,37 +14,38 @@
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"order": [[ 0, "asc" ], [2, "asc"], [ 3, "asc" ], [4, "asc"]],
"data": [% results %],
"columns": [
{
data: 'location',
render: function(data, type, row, meta) {
"data": 'location',
"render": function(data, type, row, meta) {
if (data) {
return '<a href="[% search_device %]&q=' + data + '&location=' + data + '">' + data + '</a>';
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '&location=' + encodeURIComponent(data) + '">' + he.encode(data) + '</a>';
} else {
return '[Not Set]';
}
}
}, {
data: 'ip',
render: function(data, type, row, meta) {
return '<a href="[% uri_for('/device') %]?q=' + data + '">' + (row.dns || row.ip) + '</a>';
"data": 'ip',
"render": function(data, type, row, meta) {
return '<a href="[% uri_for('/device') %]?q=' + encodeURIComponent(data) + '">' + he.encode(row.dns || row.ip) + '</a>';
}
}, {
data: 'name',
render: function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + data + '&model=' + data + '">' + data + '</a>';
"data": 'name',
"render": function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '&model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
data: 'vendor',
render: function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + data + '&model=' + data + '">' + data + '</a>';
"data": 'vendor',
"render": function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '&model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
data: 'model',
render: function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + data + '&model=' + data + '">' + data + '</a>';
"data": 'model',
"render": function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '&model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}
]

View File

@@ -12,27 +12,37 @@
<script type="text/javascript">
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"data": [% results %],
"columns": [
{
data: 'ip',
render: function(data, type, row, meta) {
return '<a search_device %]&q=' + data + '">' + (row.ip || row.name) + '</a>';
}
}, {
data: 'dns'
}, {
data: 'ip'
}, {
data: 'contact'
}, {
data: 'location'
}
]
});
var table = $('#data-table').dataTable({
"deferRender": true,
"data": [% results %],
"columns": [
{
"data": 'ip',
"render": function(data, type, row, meta) {
return '<a search_device %]&q=' + encodeURIComponent(data) + '">' + he.encode(row.ip || row.name) + '</a>';
}
}, {
"data": 'dns',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'ip',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'contact',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'location',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}
]
});
});
</script>

View File

@@ -47,66 +47,74 @@ function capitaliseFirstLetter(string) {
}
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"data": [% results %],
"columns": [
[% IF opt %] {
data: 'ip',
render: function(data, type, row, meta) {
return '<a href="[% uri_for('/device') %]?tab=modules&q=' + data + '">' + (row.device.dns || row.device.name || row.ip) + '</a>';
}
}, {
data: 'description',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?description=' + data + '">' + data + '</a>';
}
}, {
data: 'name',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?name=' + data + '">' + data + '</a>';
}
}, {
data: 'class',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + data + '">' + capitaliseFirstLetter(data) + '</a>';
}
}, {
data: 'type',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?type=' + data + '">' + data + '</a>';
}
}, {
data: 'model',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?model=' + data + '">' + data + '</a>';
}
}, {
data: 'serial',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?serial=' + data + '">' + data + '</a>';
}
}, {
data: 'hw_ver'
}, {
data: 'sw_ver'
}, {
data: 'fw_ver'
}
[% ELSE %] {
data: 'class',
render: function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + data + '">' + capitaliseFirstLetter(data) + '</a>';
}
}, {
data: 'count',
render: function(data, type, full, meta) {
return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
[% END %]
]
});
var table = $('#data-table').dataTable({
"deferRender": true,
"data": [% results %],
"columns": [
[% IF opt %] {
"data": 'ip',
"render": function(data, type, row, meta) {
return '<a href="[% uri_for('/device') %]?tab=modules&q=' + encodeURIComponent(data) + '">' + he.encode(row.device.dns || row.device.name || row.ip) + '</a>';
}
}, {
"data": 'description',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?description=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'name',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?name=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'class',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitaliseFirstLetter(data)) + '</a>';
}
}, {
"data": 'type',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?type=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'model',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'serial',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?serial=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'hw_ver',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'sw_ver',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'fw_ver',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}
[% ELSE %] {
"data": 'class',
"render": function(data, type, full, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitaliseFirstLetter(data)) + '</a>';
}
}, {
"data": 'count',
"render": function(data, type, full, meta) {
return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
[% END %]
]
});
});
</script>

View File

@@ -11,31 +11,35 @@
<script type="text/javascript">
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"order": [[ 0, "asc" ], [1, "asc"]],
"data": [% results %],
"columns": [
{
"data": 'ip',
"render": function(data, type, row, meta) {
return (row.dns || row.name || row.ip);
}
}, {
"data": 'port',
"render": function(data, type, row, meta) {
return '<a href="[% device_ports %]&q=' + row.ip + '&f=' + data + '&c_nodes=on">' + data + '</a>';
}
}, {
"data": 'description'
}, {
"data": 'up_admin',
"orderable": false,
"searchable": false,
}
]
});
var table = $('#data-table').dataTable({
"deferRender": true,
"order": [[ 0, "asc" ], [1, "asc"]],
"columns": [
{
"data": 'ip',
"render": function(data, type, row, meta) {
return he.encode(row.dns || row.name || row.ip);
}
}, {
"data": 'port',
"render": function(data, type, row, meta) {
return '<a href="[% device_ports %]&q=' + encodeURIComponent(row.ip) + '&f=' + encodeURIComponent(data) + '&c_nodes=on">' + he.encode(data) + '</a>';
}
}, {
"data": 'description',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'up_admin',
"orderable": false,
"searchable": false,
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}
],
"data": [% results %]
});
});
</script>

View File

@@ -7,46 +7,40 @@
<th>STP Status</th>
</tr>
</thead>
</tbody>
[% FOREACH row IN results %]
<tr>
<td>[% row.dns || row.name || row.ip | html_entity %]</td>
<td class="nd_center-cell"><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]&c_nodes=on">
[% row.port | html_entity %]</a></td>
<td class="nd_center-cell">[% row.description | html_entity %]</td>
<td class="nd_center-cell">[% row.stp | html_entity %]</td>
</tr>
[% END %]
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"order": [[ 0, "asc" ], [1, "asc"]],
"data": [% results %],
"columns": [
{
"data": 'ip',
"render": function(data, type, row, meta) {
return (row.dns || row.name || row.ip);
}
}, {
"data": 'port',
"render": function(data, type, row, meta) {
return '<a href="[% device_ports %]&q=' + row.ip + '&f=' + data + '&c_nodes=on">' + data + '</a>';
}
}, {
"data": 'description'
}, {
"data": 'stp',
"orderable": false,
"searchable": false,
}
]
});
var table = $('#data-table').dataTable({
"deferRender": true,
"order": [[ 0, "asc" ], [1, "asc"]],
"data": [% results %],
"columns": [
{
"data": 'ip',
"render": function(data, type, row, meta) {
return he.encode(row.dns || row.name || row.ip);
}
}, {
"data": 'port',
"render": function(data, type, row, meta) {
return '<a href="[% device_ports %]&q=' + encodeURIComponent(row.ip) + '&f=' + encodeURIComponent(data) + '&c_nodes=on">' + he.encode(data) + '</a>';
}
}, {
"data": 'description',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'stp',
"orderable": false,
"searchable": false,
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}
]
});
});
</script>