diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index dbbb45a16a4..3862cb2479f 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -3403,12 +3403,13 @@ GitRemote::GitRemote(const QString &url) if (!match.hasMatch()) return; + bool ok = false; protocol = match.captured("protocol"); userName = match.captured("user"); host = match.captured("host"); - port = match.captured("port").toUShort(); + port = match.captured("port").toUShort(&ok); path = match.captured("path"); - isValid = true; + isValid = ok || match.captured("port").isEmpty(); } } // namespace Internal diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 6d5001ece74..51703db2d6f 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -1599,6 +1599,12 @@ void GitPlugin::testGitRemote_data() .host("code.qt.io") .port(80) .path("/qt-creator/qt-creator.git"); + QTest::newRow("invalid-port") + << RemoteTest("https://code.qt.io:99999/qt-creator/qt-creator.git") + .protocol("https") + .host("code.qt.io") + .path("/qt-creator/qt-creator.git") + .isValid(false); QTest::newRow("ssh-user-foo") << RemoteTest("ssh://foo@codereview.qt-project.org:29418/qt-creator/qt-creator.git") .protocol("ssh")