Mercurial > hg > orthanc
comparison OrthancServer/OrthancExplorer/explorer.js @ 4910:92e84e9d2cca
Orthanc Explorer: sanitize DICOM tag display
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 21 Feb 2022 13:01:18 +0100 |
parents | 6eff25f70121 |
children | 0ea402b4d901 |
comparison
equal
deleted
inserted
replaced
4909:1cd1b8f58e56 | 4910:92e84e9d2cca |
---|---|
356 v = FormatFloatSequence(v); | 356 v = FormatFloatSequence(v); |
357 } | 357 } |
358 | 358 |
359 target.append($('<p>') | 359 target.append($('<p>') |
360 .text(tags[i].Name + ': ') | 360 .text(tags[i].Name + ': ') |
361 .append($('<strong>').html(v))); | 361 .append($('<strong>').text(v))); |
362 } | 362 } |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 | 366 |
462 dataType: 'json', | 462 dataType: 'json', |
463 async: false, | 463 async: false, |
464 cache: false, | 464 cache: false, |
465 success: function(s) { | 465 success: function(s) { |
466 if (s.Name != "") { | 466 if (s.Name != "") { |
467 $('.orthanc-name').html($('<a>') | 467 $('.orthanc-name').empty(); |
468 $('.orthanc-name').append($('<a>') | |
468 .addClass('ui-link') | 469 .addClass('ui-link') |
469 .attr('href', 'explorer.html') | 470 .attr('href', 'explorer.html') |
470 .text(s.Name) | 471 .text(s.Name) |
471 .append(' » ')); | 472 .append(' » ')); |
472 } | 473 } |
859 }); | 860 }); |
860 } | 861 } |
861 } | 862 } |
862 | 863 |
863 | 864 |
864 function EscapeHtml(value) | |
865 { | |
866 var ENTITY_MAP = { | |
867 '&': '&', | |
868 '<': '<', | |
869 '>': '>', | |
870 '"': '"', | |
871 "'": ''', | |
872 '/': '/', | |
873 '`': '`', | |
874 '=': '=' | |
875 }; | |
876 | |
877 return String(value).replace(/[&<>"'`=\/]/g, function (s) { | |
878 return ENTITY_MAP[s]; | |
879 }); | |
880 } | |
881 | |
882 | |
883 function ConvertForTree(dicom) | 865 function ConvertForTree(dicom) |
884 { | 866 { |
885 var result = []; | 867 var result = []; |
886 var label, c; | 868 var label, c; |
887 | 869 |
888 for (var i in dicom) { | 870 for (var i in dicom) { |
889 if (dicom[i] != null) { | 871 if (dicom[i] != null) { |
890 label = (i + '<span class="tag-name"> (<i>' + | 872 var spanElement = $("<span>", { |
891 EscapeHtml(dicom[i]["Name"]) + | 873 class:"tag-name" |
892 '</i>)</span>: '); | 874 }); |
893 | 875 var iElement = $("<i>", { |
876 text: dicom[i]["Name"] | |
877 }); | |
878 | |
879 spanElement.append(" ("); | |
880 spanElement.append(iElement); | |
881 spanElement.append(")"); | |
882 | |
883 label = (i + spanElement.prop('outerHTML') + ': '); | |
894 if (dicom[i]["Type"] == 'String') | 884 if (dicom[i]["Type"] == 'String') |
895 { | 885 { |
886 var strongElement = $('<strong>', { | |
887 text: dicom[i]["Value"] | |
888 }); | |
889 | |
896 result.push({ | 890 result.push({ |
897 label: label + '<strong>' + EscapeHtml(dicom[i]["Value"]) + '</strong>', | 891 label: label + strongElement.prop('outerHTML'), |
898 children: [] | 892 children: [] |
899 }); | 893 }); |
900 } | 894 } |
901 else if (dicom[i]["Type"] == 'TooLong') | 895 else if (dicom[i]["Type"] == 'TooLong') |
902 { | 896 { |
1203 { | 1197 { |
1204 items.append('<li data-role="list-divider">DICOM modalities</li>'); | 1198 items.append('<li data-role="list-divider">DICOM modalities</li>'); |
1205 | 1199 |
1206 for (var i = 0; i < modalities.length; i++) { | 1200 for (var i = 0; i < modalities.length; i++) { |
1207 name = modalities[i]; | 1201 name = modalities[i]; |
1208 item = $('<li>') | 1202 |
1209 .html('<a href="#" rel="close">' + name + '</a>') | 1203 var liElement = $('<li>', { |
1210 .attr('name', name) | 1204 name: name |
1205 }) | |
1211 .click(function() { | 1206 .click(function() { |
1212 clickedModality = $(this).attr('name'); | 1207 clickedModality = $(this).attr('name'); |
1213 }); | 1208 }); |
1214 items.append(item); | 1209 |
1210 var aElement = $('<a>', { | |
1211 href: '#', | |
1212 rel: 'close', | |
1213 text: name | |
1214 }) | |
1215 liElement.append(aElement); | |
1216 | |
1217 items.append(liElement); | |
1215 } | 1218 } |
1216 } | 1219 } |
1217 | 1220 |
1218 // Retrieve the list of the known Orthanc peers | 1221 // Retrieve the list of the known Orthanc peers |
1219 $.ajax({ | 1222 $.ajax({ |
1229 { | 1232 { |
1230 items.append('<li data-role="list-divider">Orthanc peers</li>'); | 1233 items.append('<li data-role="list-divider">Orthanc peers</li>'); |
1231 | 1234 |
1232 for (var i = 0; i < peers.length; i++) { | 1235 for (var i = 0; i < peers.length; i++) { |
1233 name = peers[i]; | 1236 name = peers[i]; |
1234 item = $('<li>') | 1237 |
1235 .html('<a href="#" rel="close">' + name + '</a>') | 1238 var liElement = $('<li>', { |
1236 .attr('name', name) | 1239 name: name |
1240 }) | |
1237 .click(function() { | 1241 .click(function() { |
1238 clickedPeer = $(this).attr('name'); | 1242 clickedPeer = $(this).attr('name'); |
1239 }); | 1243 }); |
1240 items.append(item); | 1244 |
1245 var aElement = $('<a>', { | |
1246 href: '#', | |
1247 rel: 'close', | |
1248 text: name | |
1249 }) | |
1250 liElement.append(aElement); | |
1251 | |
1252 items.append(liElement); | |
1241 } | 1253 } |
1242 } | 1254 } |
1243 | 1255 |
1244 // Launch the dialog | 1256 // Launch the dialog |
1245 $('#dialog').simpledialog2({ | 1257 $('#dialog').simpledialog2({ |