From 52e56025f7cfb5c922d12370b77cc1c13beb1d31 Mon Sep 17 00:00:00 2001 From: luccioman Date: Tue, 20 Sep 2016 02:44:28 +0200 Subject: [PATCH] Fixed undefined error case in sorttable.js Occured when a table with class="sortable" has data cells with colspan attribute greater than 1 --- htroot/js/sorttable.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/htroot/js/sorttable.js b/htroot/js/sorttable.js index fa0bd698d..5ea846f79 100644 --- a/htroot/js/sorttable.js +++ b/htroot/js/sorttable.js @@ -3,6 +3,7 @@ version 2 7th April 2007 Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + fixed for YaCy 20th September 2016 Instructions: Download this file @@ -17,7 +18,7 @@ @licstart The following is the entire license notice for the JavaScript code in this file. - Copyright (c) 1997-2007 Stuart Langridge + Copyright (c) 1997-2007, 2016 Stuart Langridge, luccioman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -172,7 +173,7 @@ sorttable = { col = this.sorttable_columnindex; rows = this.sorttable_tbody.rows; for (var j=0; j 0 ? tableRow.cells[cellIndex].colspan : 1; + columnIndex += colspan; + } + /* This final test ensure we do not use an index out of bounds */ + if(cellIndex < cellsNb) { + cellText = sorttable.getInnerText(tableRow.cells[cellIndex]); + } + return cellText; + }, + guessType: function(table, column) { // guess the type of a column based on its first non-blank row sortfn = sorttable.sort_alpha; for (var i=0; i