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: Invalid URI when open invalid path #6560

Merged
merged 2 commits into from May 16, 2019

Conversation

@RussKie
Copy link
Member

commented May 14, 2019

Proposed changes

Attempt to open a repository at an invalid path (e.g. "C:" instead of "C:\") would result in the following error:

System.UriFormatException
  HResult=0x80131537
  Message=Invalid URI: The format of the URI could not be determined.
  Source=System
  StackTrace:
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at GitCommands.PathUtil.NormalizePath(String path)
   at GitCommands.GitModule..ctor(String workingDir)
   at GitUI.CommandsDialogs.BrowseDialog.FormOpenDirectory.LoadClick(Object sender, EventArgs e)

The fix adds checks around the user supplied path.

Relates to #6549
Relates to #6556

Test methodology

  • manual
  • add unit test

✒️ I contribute this code under The Developer Certificate of Origin.

@RussKie RussKie requested review from gerhardol and mstv May 14, 2019
@ghost ghost assigned RussKie May 14, 2019
@ghost ghost added the status: ready label May 14, 2019
@codecov

This comment has been minimized.

Copy link

commented May 14, 2019

Codecov Report

Merging #6560 into master will increase coverage by 0.04%.
The diff coverage is 93.47%.

@@            Coverage Diff             @@
##           master    #6560      +/-   ##
==========================================
+ Coverage   47.09%   47.14%   +0.04%     
==========================================
  Files         697      698       +1     
  Lines       52545    52586      +41     
  Branches     6890     6893       +3     
==========================================
+ Hits        24748    24793      +45     
+ Misses      26475    26467       -8     
- Partials     1322     1326       +4
Flag Coverage Δ
#production 36.48% <83.33%> (+0.02%) ⬆️
#tests 97.59% <100%> (ø) ⬆️
@RussKie

This comment was marked as resolved.

Copy link
Member Author

commented May 14, 2019

@RussKie RussKie force-pushed the RussKie:fix_invalid_uri branch from a23bb27 to 13bf26e May 14, 2019
@mstv

This comment has been minimized.

Copy link
Member

commented May 14, 2019

It just eats the exception.
But the list of branches for URLs like "git@host:path.git" remains empty in the Add submodule dialog.
Then a random branch is chosen when you press Add.

@RussKie RussKie force-pushed the RussKie:fix_invalid_uri branch from 13bf26e to e9fc4e2 May 15, 2019
RussKie added 2 commits May 14, 2019
Attempt to open a repository at an invalid path (e.g. "C:" instead of
"C:\") would result in the following error:

    System.UriFormatException
      HResult=0x80131537
      Message=Invalid URI: The format of the URI could not be determined.
      Source=System
      StackTrace:
       at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
       at GitCommands.PathUtil.NormalizePath(String path)
       at GitCommands.GitModule..ctor(String workingDir)
       at GitUI.CommandsDialogs.BrowseDialog.FormOpenDirectory.LoadClick(Object sender, EventArgs e)

The fix adds checks around the user supplied path.

Relates to #6549
Relates to #6556
@RussKie RussKie force-pushed the RussKie:fix_invalid_uri branch from e9fc4e2 to 36793cf May 16, 2019
@RussKie RussKie merged commit d017a23 into gitextensions:master May 16, 2019
3 checks passed
3 checks passed
CodeFactor No issues found.
Details
WIP Ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@ghost ghost removed the status: ready label May 16, 2019
@RussKie RussKie modified the milestones: 3.1.1, 3.2.0 May 16, 2019
@RussKie RussKie deleted the RussKie:fix_invalid_uri branch May 19, 2019
gerhardol added a commit to gerhardol/gitextensions that referenced this pull request Jun 16, 2019
fix: Invalid URI when open invalid path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.