From 5456f5a70a0a82e5cf15d83dac68fd2b17a144e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 17 May 2018 10:28:24 +0200 Subject: [PATCH] Fix potential for invalid sorting of uploads "date" and "size" might be undefined on both parameters (e.g. for folders, SD files). We have no guarantee that "a" will always have either defined, so make sure to test or a wrong sorting order might be the consequence. Fixes #2355 --- src/octoprint/static/js/app/viewmodels/files.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 2e8634bfa..0724490da 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -99,13 +99,13 @@ $(function() { "upload": function(a, b) { // sorts descending if (b["date"] === undefined || a["date"] > b["date"]) return -1; - if (a["date"] < b["date"]) return 1; + if (a["date"] === undefined || a["date"] < b["date"]) return 1; return 0; }, "size": function(a, b) { // sorts descending if (b["size"] === undefined || a["size"] > b["size"]) return -1; - if (a["size"] < b["size"]) return 1; + if (a["size"] === undefined || a["size"] < b["size"]) return 1; return 0; } },