From 37a725d034c44249773ca4cf83291a93129f73e4 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 28 Jan 2013 20:23:06 +0100 Subject: [PATCH] Guard against users putting strings with thousands of periods into custom columns and then saying they are hierarchical --- src/calibre/gui2/tag_browser/model.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index 2d6f40690b..742f2b2776 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -188,12 +188,14 @@ class TagTreeItem(object): # {{{ def child_tags(self): res = [] - def recurse(nodes, res): + def recurse(nodes, res, depth): + if depth > 100: + return for t in nodes: if t.type != TagTreeItem.CATEGORY: res.append(t) - recurse(t.children, res) - recurse(self.children, res) + recurse(t.children, res, depth+1) + recurse(self.children, res, 1) return res # }}}