error when sorting tables with a lot of text in cells
Message-ID: <58455b37.q0KqRoQ55eaEjW9T%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: eb6439343f6197fb31e4cbf095a50a877823ceb8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eb6439343f6197…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 5 13:18:42 2016 +0100
4127 FIX Fixed possible "maximum recursion depth exceeded" error when sorting
tables with a lot of text in cells
---
.werks/4127 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/lib.py | 24 +++++++++---------------
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/.werks/4127 b/.werks/4127
new file mode 100644
index 0000000..7a1d96f
--- /dev/null
+++ b/.werks/4127
@@ -0,0 +1,10 @@
+Title: Fixed possible "maximum recursion depth exceeded" error when sorting
tables with a lot of text in cells
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1480940237
+
+
diff --git a/ChangeLog b/ChangeLog
index 55f38d6..2dd9262 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
* 4071 FIX: Removed notes_url from "LOG *" logwatch services...
* 4072 FIX: Fixed multiple issues in BI availability when groups or names contain
umlauts
* 4080 FIX: Fixed possible exception "unsupported operand type" in matrix
views
+ * 4127 FIX: Fixed possible "maximum recursion depth exceeded" error when
sorting tables with a lot of text in cells
WATO:
* 3984 Permissions can now be filtered by providing a search term on the "edit
role" page...
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 913a492..da18e42 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -368,21 +368,15 @@ release_all_locks = store.release_all_locks
# into int datatype. That way a naturual sort can be
# implemented.
def num_split(s):
- if not s:
- return ()
- elif s[0].isdigit():
- first_num = regex("[^0-9]").split(s)[0]
- return ( int(first_num), ) + num_split(s[len(first_num):])
- else:
- first_word = regex("[0-9]").split(s)[0]
- return ( first_word.lower(), ) + num_split(s[len(first_word):])
-
- # exp = int(math.log10(x))
- # mantissa = x / 10**exp
- # if mantissa < 1:
- # mantissa *= 10
- # exp -= 1
- # return mantissa, exp
+ parts = []
+ for part in re.split('(\d+)', s):
+ try:
+ parts.append(int(part))
+ except ValueError:
+ parts.append(part)
+
+ return tuple(parts)
+
def cmp_service_name_equiv(r):
if r == "Check_MK":