Repository: nvaccess/nvda

Issue:
ARIA rowindex, colindex, rowcount and colcount can cause bug in Firefox

### Steps to reproduce:
In Firefox, open: `data:text/html,<div role="grid" aria-colcount>Test</div>`

### Actual behavior:

The HTML document is not accessible and the following traceback is present in the log:

```
Traceback (most recent call last):
  File "scriptHandler.pyc", line 208, in executeScript
  File "cursorManager.pyc", line 252, in script_moveByLine_back
  File "cursorManager.pyc", line 162, in _caretMovementScriptHelper
  File "speech\speech.pyc", line 1150, in speakTextInfo
  File "speech\types.pyc", line 42, in __iter__
  File "speech\speech.pyc", line 1190, in getTextInfoSpeech
  File "virtualBuffers\__init__.pyc", line 294, in getTextWithFields
  File "virtualBuffers\__init__.pyc", line 283, in _getFieldsInRange
  File "virtualBuffers\__init__.pyc", line 285, in <listcomp>
  File "virtualBuffers\__init__.pyc", line 271, in _normalizeCommand
  File "virtualBuffers\gecko_ia2.pyc", line 90, in _normalizeControlField
ValueError: invalid literal for int() with base 10: ''
```

### Expected behavior:
No error and read "Test".

### System configuration
#### NVDA installed/portable/running from source:
Both

#### NVDA version:
alpha-24825,4c3a67b2

#### Windows version:
10 21H2

#### Name and version of other software in use when reproducing the issue:
Firefox 97.0.1

#### Other information about your system:
N/A

### Other questions
#### Does the issue still occur after restarting your computer?
Yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes, same behavior.

#### If add-ons are disabled, is your problem still occurring?
Yes

#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
Yes



Discussion:

Resolving patch:
diff --git a/source/virtualBuffers/gecko_ia2.py b/source/virtualBuffers/gecko_ia2.py
--- a/source/virtualBuffers/gecko_ia2.py
+++ b/source/virtualBuffers/gecko_ia2.py
@@ -1,7 +1,7 @@
 # A part of NonVisual Desktop Access (NVDA)
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
-# Copyright (C) 2008-2021 NV Access Limited, Babbage B.V., Mozilla Corporation, Accessolutions, Julien Cochuyt
+# Copyright (C) 2008-2022 NV Access Limited, Babbage B.V., Mozilla Corporation, Accessolutions, Julien Cochuyt
 
 import typing
 import weakref
@@ -84,10 +84,17 @@ def _calculateDescriptionFrom(self, attrs: textInfos.ControlField) -> controlTyp
 	# Note: when working on _normalizeControlField, look for opportunities to simplify
 	# and move logic out into smaller helper functions.
 	def _normalizeControlField(self, attrs):  # noqa: C901
-		for attr in ("table-rownumber-presentational","table-columnnumber-presentational","table-rowcount-presentational","table-columncount-presentational"):
-			attrVal=attrs.get(attr)
-			if attrVal is not None:
-				attrs[attr]=int(attrVal)
+		for attr in (
+			"table-rownumber-presentational",
+			"table-columnnumber-presentational",
+			"table-rowcount-presentational",
+			"table-columncount-presentational"
+		):
+			attrVal = attrs.get(attr)
+			if attrVal is not None and attrVal.lstrip('-').isdigit():
+				attrs[attr] = int(attrVal)
+			else:
+				attrs[attr] = None
 
 		attrs["_description-from"] = self._calculateDescriptionFrom(attrs)
 		attrs.update(_getNormalizedCurrentAttrs(attrs))


Test patch: