Skip to content

Stop regex_error exception when quick navigating to article landmarks#9299

Merged
michaelDCurran merged 6 commits into
masterfrom
i8980
Feb 21, 2019
Merged

Stop regex_error exception when quick navigating to article landmarks#9299
michaelDCurran merged 6 commits into
masterfrom
i8980

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #8980

Summary of the issue:

NvDA's browseMode quick navigation in virtualBuffers uses regular expressions to match on a node's attributes to locate the next valid item.
However, in certain scenarios, Firefox can seem to freeze when quick navigating by landmarks, if the extendedAria add-on in installed and reportArticles is enabled.
Technically:
In Firefox at least, it seems that the c++ regex_match function can throw a regex_error exception if the input string is too long. For instance, if searching for landmarks (including articles) and it comes upon an article node with an aria-label with a length greater than 294 characters.

Description of how this pull request fixes the issue:

  1. We now catch regex_error thrown by regex_match, log a debug warning, and return false (I.e. pretend the regex did not match). This in itself stops the freeze, but does mean that a possible article will be skipped.
  2. We limit the length of attribute value strings added to re regular expression input to 100 characters. Currently this is for all attribute values, as matchAttributes is really supposed to be agnostic to what attributes it is dealing with. Though we could specifically hardcode a check for 'name'. I can't however really think of a situation where any attribute value needs to be more than 100 characters for matching purposes. We could instead also up the limit to say 256, or in deed 294, but I have a feeling this may not be universal across machines.

Testing performed:

Tested the original testcases in #8980. The correct articles were found, and no freeze occured.

Known issues with pull request:

None.

Change log entry:

Bug fixes:

…en using them in regular expressions when finding nodes. Also catch regex_error thrown by regex_match.
Comment thread nvdaHelper/vbufBase/storage.cpp

@jcsteh jcsteh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that because this count is before expansion, the truncated string might actually be longer than 100 chars. I don't think that really matters, though, and the alternative is more confusing.

Comment thread nvdaHelper/vbufBase/storage.cpp Outdated
// @param out the stream to which the escaped attribute string should be written
// @param text The attribute string to be escaped
// @param maxLength the maximum length of the attribute string that should be copied. If maxLength is 0 or not specified, the entire string is copied.
// @return the number of characters written to the output stream (before expantion / filtering). This number can be used to see if the string was truncated at all.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: expantion -> expansion (s instead of t)

@michaelDCurran michaelDCurran merged commit ff9dcca into master Feb 21, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.1 milestone Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Freeze when navigating by landmarks with certain labeled article landmarks

3 participants