Repository navigation
Normalize bare drive paths when creating portable copy - #20973
Closed
SohamXYZDev wants to merge 1 commit into
Closed
SohamXYZDev wants to merge 1 commit into
SohamXYZDev wants to merge 1 commit into
Conversation
Collaborator
|
Closing per the AI policy.
If you would like to contribute in future, ensure you:
|
Author
|
Understood, sorry for the trouble, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #20159
Summary of the issue:
When creating a portable copy of NVDA via the "Create Portable NVDA" dialog, entering a bare top-level drive without a trailing backslash (such as
D:orc:) triggers an error dialog asking for an absolute path.On Windows,
os.path.isabs("D:")evaluates toFalsebecause Win32 treats a bare drive letter without a trailing slash as a drive-relative path rather than the drive root (D:\).Description of user facing changes:
Users can now enter a bare top-level drive letter without a trailing backslash (e.g.
d:orD:) into the destination path field when creating a portable copy of NVDA without encountering an error dialog.Description of developer facing changes:
Added
_normalizePortablePathingui.installerGuiwhich trims whitespace, expands environment variables, and normalizes bare drive inputs matching^[a-zA-Z]:$to drive root paths by appending the path separator prior to absolute path validation. BothonCreatePortableanddoCreatePortableuse this normalization.Description of development approach:
In
source/gui/installerGui.py:_normalizePortablePath(path)to expand environment variables and appendos.septo bare drive strings (^[a-zA-Z]:$).PortableCreationDialog.onCreatePortable, user input is normalized with_normalizePortablePathbefore theos.path.isabs()check.doCreatePortable,portableDirectoryis normalized so programmatic/CLI callers specifying--create-portable --portable-path D:also benefit from normalization.tests/unit/test_installer.pycovering bare drives, casing, whitespace padding, UNC paths, and environment variables.Testing strategy:
Manual testing on Windows 10:
Tested the normalization and validation flow directly on Windows 10:
D:-> normalized toD:\,os.path.isabs()returnsTrue, proceeds without error dialog.c:-> normalized toc:\.E:-> whitespace stripped, normalized toE:\.relative/path,D:relative) -> correctly rejected as non-absolute.%SYSTEMDRIVE%-> expanded toC:and normalized toC:\.Automated testing:
Ran test suite in
tests/unit/test_installer.py(10 passing tests in 0.003s) validating path handling across all cases.Known issues with pull request:
None.
Code Review Checklist: