Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid regex expressions in dictionaries no longer causes crash. #6136

Merged
merged 2 commits into from Jul 20, 2016

Conversation

feerrenrut
Copy link
Contributor

This change introduces a safety check when loading speech dictionaries, to ensure that nvda does not crash if the dictionaries contain invalid regex. This change also catches the same situation in the UI and informs the user that the regex is invalid.

Fixes #4834

@feerrenrut
Copy link
Contributor Author

@michaelDCurran Mind taking a look at this?

@michaelDCurran
Copy link
Member

When loading a SpeechDict, we could have individual DictionaryEntry lines ignored if they are invalid, rather than the first invalid line causing the whole dictionary not to load. I.e. a try except around the call to DictionaryEntry within SpeechDict.load. Ensure though that the 'comment' variable is cleared in a 'finally' block. This change would also allow you to log either the content or line number, for the offending line.
It is also worth noting that the error presented to the user in the UI coming from an invalid regular expression is not translatable. Though really there is nothing that can be done about this -- these strings are hardcoded in the regexp engine. At very least perhaps we could format the error text like _('Regular Expression error "%s"')%error
then the quotes would go some way to suggesting why that is not translatable.

When adding a dictionary entry with invalid regex, the error message now
states that this is a regex error and qoutes the error. It is
unfortunate, but the regex error is difficult to translate.

If a user does manage to introduce an error into a dictionary file, then
the nvda will import all valid lines in the file, reporting warnings to
the log for lines in the dictionary that are invalid.
@feerrenrut
Copy link
Contributor Author

Incubated in 3a5c527

@feerrenrut feerrenrut merged commit 13e7232 into master Jul 20, 2016
@feerrenrut feerrenrut deleted the i4834-BadRegexInDictCausesCrash branch January 17, 2020 09:04
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.

None yet

2 participants