I know the focus is on the API, but when I put this together and added the JQuery front end, I noticed that the todo name is not being encoded and is vulnerable to cross-site scripting. This has to do with the technique of just building up the table's rows using concatenation and appending it as HTML. While not as smooth, something like this may work to build that table and encode the name.
var tr = $('<tr>');
$('<td><input disabled="true" type="checkbox" ' + checked + '></td>').appendTo(tr);
var td = $('<td>');
td.text(item.name);
td.appendTo(tr);
$('<td><button onclick="editItem(' + item.id + ')">Edit</button></td>' +
'<td><button onclick="deleteItem(' + item.id + ')">Delete</button></td>').appendTo(tr);
tr.appendTo($('#todos'));
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@jamesjardine thanks.
@scottaddie please review. Should I bump this up to @blowdart ?
@MikeWasson FYI.
@Rick-Anderson Let's have Barry weigh in on this.
@blowdart customer discovered vulnerable to cross-site scripting. Please comment and set priority.
Oh dear. Yes, you could probably optimise a bit more;
var $tr = $('<tr>').append(
$('<td>').text(...),
$('<td>').text(item.name),
$('<td>').text(...)
@fiyazbinhasan can you fix this JavaScript?
@Rick-Anderson sure! @blowdart already provided the solution. I'll fix the getdata() method by tomorrow.
@Rick-Anderson @blowdart @jamesjardine please check https://github.com/aspnet/Docs/pull/9415