[orca] Sanity-check values app provides in response to getTextAtOffset()



commit 9c654e4f8c7b3d80cba85ce7b20c8a3bbe2eed57
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Mar 22 13:57:14 2017 -0400

    Sanity-check values app provides in response to getTextAtOffset()

 src/orca/scripts/default.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 2a74610..8554c6a 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3491,6 +3491,13 @@ class Script(script.Script):
                     [lineString, startOffset, endOffset] = \
                         text.getTextAtOffset(offset, mode)
 
+                if endOffset > text.characterCount:
+                    msg = "WARNING: endOffset: %i > characterCount: %i " \
+                          " resulting from text.getTextAtOffset(%i, %s) for %s" \
+                          % (endOffset, text.characterCount, offset, mode, obj)
+                    debug.println(debug.LEVEL_INFO, msg, True)
+                    endOffset = text.characterCount
+
                 # [[[WDW - HACK: this is here because getTextAtOffset
                 # tends not to be implemented consistently across toolkits.
                 # Sometimes it behaves properly (i.e., giving us an endOffset


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]