Skip to content

Unable to use backslash in the replacement value of dictionaries #14556

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

Closed
CyrilleB79 opened this issue Jan 17, 2023 · 3 comments · Fixed by #14557
Closed

Unable to use backslash in the replacement value of dictionaries #14556

CyrilleB79 opened this issue Jan 17, 2023 · 3 comments · Fixed by #14557
Labels
p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@CyrilleB79
Copy link
Collaborator

CyrilleB79 commented Jan 17, 2023

Context

Issue found while while reviewing the list of modified files in SVN update status window.

Steps to reproduce:

  • Open a new entry in the temporary dictionary
  • Ine pattern field put "p:\a\very\long\path\to\my\project\root\folder\"
  • In replace field, put: "root\"
  • Leave other fields as they are, specifically leave the radio button type on "Anywhere"
  • Press OK

Actual behavior:

I get the following error message box:

Regular Expression error: "bad escape (end of pattern) at position 4".

Expected behavior:

  • When regular expression is not selected as entry type, I should be able to use backslash character normally in the dictionary replace field.
  • I should not get any message related to regexps if I have not selected "Regular expression" as dictionary entry type.

NVDA logs, crash dumps and other attachments:

Following debugWarning found in the log:

DEBUGWARNING - gui.speechDict.DictionaryEntryDialog.onOk (17:27:09.948) - MainThread (19688):
Could not add dictionary entry due to (regex error) : bad escape (end of pattern) at position 4

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

2022.4

Windows version:

Windows 10 20H2 (AMD64) build 19042.2364

Name and version of other software in use when reproducing the issue:

N/A

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.

Not tested but surely not new.

If NVDA 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?

Not tested;unrelated.

@XLTechie
Copy link
Collaborator

XLTechie commented Jan 17, 2023 via email

@CyrilleB79
Copy link
Collaborator Author

I can not replicate with the STR given, in alpha 27541. System language is English.

Thanks for reporting. Sorry, there was a formatting issue. I have updated the initial description, this should be OK now.

@XLTechie
Copy link
Collaborator

XLTechie commented Jan 17, 2023 via email

@seanbudd seanbudd added p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation. labels Feb 14, 2023
seanbudd pushed a commit that referenced this issue Feb 14, 2023
Fixes #14556

Summary of the issue:
Dictionaries do not allow to use backslash character normally in the replacement field when regexp is not selected as entry type. When such a character is used, a message box complaining of a regexp error appears.

Description of user facing changes
The user can use backslash in replacement field normally when entry type is not regexp
Error messages are more precise and more specific when entering erroneous values in the fields for a regexp entry
Description of development approach
When the entry type is not regexp, escape the replacement string
When entries are created:
filter exception on re.error instead of the too global Exception to catch only exceptions related to regexps
separate the try/except statement in two in order to indicate in which field the regexp error lies
In case of a regexp error, after validating "OK" in the message box, the field where the error lies is re-focused
Reports the regexp error only in case of entry type = regexp; in the other cases,re-raise the exception, in order not to catch unrelated exceptions, e.g. code bug.
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants