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

fix(paths): trim leading and trailing whitespaces for file system paths #162

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

mahadzaryab1
Copy link
Contributor

Remove all leading and trailing whitespaces when searching the file system for a path. This PR fixes #158.

@kehoecj
Copy link
Collaborator

kehoecj commented Aug 15, 2024

@mahadzaryab1 How did you end up testing your changes on windows?

@kehoecj kehoecj self-requested a review August 15, 2024 15:17
@kehoecj kehoecj added the pr-action-requested PR is awaiting feedback from the submitting developer label Aug 15, 2024
@mahadzaryab1
Copy link
Contributor Author

mahadzaryab1 commented Aug 15, 2024

@kehoecj I ran the code on a Windows 11 VM and I can reproduce the error in v.1.6.0. It seems like in v.1.7.0, adding a trailing whitespace in front will return a Unable to find files error instead of a nil pointer dereference. The changes in this PR do not return an error on Windows for trailing and leading whitespaces.

v.1.6.0

$ ./validator.exe " C:\Users\mahad\Documents\opensource\config-file-validator\test\fixtures\uppercase-extension\good.YAML"
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x6d3945]

v.1.7.0

$ ./validator.exe " C:\Users\mahad\Documents\opensource\config-file-validator\test\fixtures\uppercase-extension\good.YAML"
2024/08/15 16:30:00 An error occurred during CLI execution: Unable to find files: CreateFile  C:\Users\mahad\Documents\opensource\config-file-validator\test\fixtures\uppercase-extension\good.YAML: The filename, directory name, or volume label syntax is incorrect.

Changes from this PR

./validator.exe " C:\Users\mahad\Documents\opensource\config-file-validator\test\fixtures\uppercase-extension\good.YAML  "
    ✓ C:\Users\mahad\Documents\opensource\config-file-validator\test\fixtures\uppercase-extension\good.YAML

@kehoecj kehoecj added waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers and removed pr-action-requested PR is awaiting feedback from the submitting developer labels Aug 15, 2024
Copy link
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the contribution and bugfix @mahadzaryab1 !

@kehoecj kehoecj merged commit 77d6a24 into Boeing:main Aug 15, 2024
10 checks passed
shiina4119 pushed a commit to shiina4119/config-file-validator that referenced this pull request Aug 23, 2024
…hs (Boeing#162)

* Remove Leading And Trailing Whitespaces For Paths

* Add Test For Leading And Trailing Whitespaces

* Add More Test Cases For Whitespaces In Middle of Path
shiina4119 pushed a commit to shiina4119/config-file-validator that referenced this pull request Oct 4, 2024
…hs (Boeing#162)

* Remove Leading And Trailing Whitespaces For Paths

* Add Test For Leading And Trailing Whitespaces

* Add More Test Cases For Whitespaces In Middle of Path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paths not trimmed throws exception when path starts with space
2 participants