[orca] Don't iterate through all children of very complex SVGs



commit 0ff2605e15ebcb8c53bbfd59dc88d5cb7156a393
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Apr 8 15:26:24 2020 -0400

    Don't iterate through all children of very complex SVGs
    
    If an SVG had children, even though it lacked any other presentable
    information, we treated it as potentially worthy of presentation.
    Then we descended the children looking for objects worthy of
    presentation. But if an SVG is sufficiently complex, it can have
    thousands of children, and any recursive method used to iterate
    through them can result in a crash. Therefore, check the first 50
    children, and if they also lack presentable information, treat the
    SVG as not being worthy of presentation.

 src/orca/scripts/web/script_utilities.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 8527f76ea..0f2f19d6a 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -3670,7 +3670,7 @@ class Utilities(script_utilities.Utilities):
         if obj.getRole() not in [pyatspi.ROLE_IMAGE, pyatspi.ROLE_CANVAS] \
            and self._getTag(obj) != 'svg':
             rv = False
-        if rv and (obj.name or obj.description or obj.childCount):
+        if rv and (obj.name or obj.description):
             rv = False
         if rv and (self.isClickableElement(obj) or self.hasLongDesc(obj)):
             rv = False
@@ -3690,6 +3690,11 @@ class Utilities(script_utilities.Utilities):
                     rv = False
         if rv and 'Text' in pyatspi.listInterfaces(obj):
             rv = self.queryNonEmptyText(obj) is None
+        if rv and obj.childCount:
+            for i in range(min(obj.childCount, 50)):
+                if not self.isUselessImage(obj[i]):
+                    rv = False
+                    break
 
         self._isUselessImage[hash(obj)] = rv
         return rv


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