From 20e7acd5d2421b53e5b2849e784e32fe93d4cac8 Mon Sep 17 00:00:00 2001 From: KaboPC Date: Fri, 30 Nov 2012 20:03:36 -0500 Subject: [PATCH 1/3] Fix index out of bounds in get_text_and_insertion_data Check size of textL before accessing.(cherry picked from commit db25b4131f3c042b3edc824550a2724433ea5b76) --- albow/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/albow/fields.py b/albow/fields.py index 9dc1816..d8ab053 100644 --- a/albow/fields.py +++ b/albow/fields.py @@ -677,7 +677,8 @@ class TextEditorWrapped(Widget): i = self.insertion_step il = self.insertion_line if i is not None: - i = max(0, min(i, len(self.textL[il]))) + if il < len(textL): + i = max(0, min(i, len(self.textL[il]))) return text, i, il def move_insertion_point(self, d): From d1de57d6b590521ba343ed058511823db4aee603 Mon Sep 17 00:00:00 2001 From: KaboPC Date: Fri, 30 Nov 2012 20:15:51 -0500 Subject: [PATCH 2/3] Update get_text_and_insertion_data to return within bounds get_text_and_insertion_data should now always only return values within the bounds of textL(cherry picked from commit d289baaf4d8ee416f9618e19eb98c8ecef27944f) --- albow/fields.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/albow/fields.py b/albow/fields.py index d8ab053..82ca293 100644 --- a/albow/fields.py +++ b/albow/fields.py @@ -676,9 +676,10 @@ class TextEditorWrapped(Widget): text = self.get_text() i = self.insertion_step il = self.insertion_line + if il is not None: + il = max(0, min(il, (len(self.textL)-1))) if i is not None: - if il < len(textL): - i = max(0, min(i, len(self.textL[il]))) + i = max(0, min(i, len(self.textL[il])-1)) return text, i, il def move_insertion_point(self, d): From c30527bae5e1a67fb21435fc0e834e7a35c9a59c Mon Sep 17 00:00:00 2001 From: KaboPC Date: Fri, 30 Nov 2012 20:36:52 -0500 Subject: [PATCH 3/3] Fix potential nonetype error Add a check in get_text_and_insertion_data to prevent a possible NoneType crash.(cherry picked from commit 056dbec8e9efebd0d9663034a8dffc95d26986dd) --- albow/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/albow/fields.py b/albow/fields.py index 82ca293..cf8691e 100644 --- a/albow/fields.py +++ b/albow/fields.py @@ -678,7 +678,7 @@ class TextEditorWrapped(Widget): il = self.insertion_line if il is not None: il = max(0, min(il, (len(self.textL)-1))) - if i is not None: + if i is not None and il is not None: i = max(0, min(i, len(self.textL[il])-1)) return text, i, il