diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSslSupport.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSslSupport.java index d2aa2f1568a8..e8b34c1ef332 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSslSupport.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSslSupport.java @@ -111,7 +111,13 @@ public class GithubSslSupport { } @CalledInAwt - public boolean askIfShouldProceed(final String host) { + public boolean askIfShouldProceed(final String url) { + String host = GithubUrlUtil.getHostFromUrl(url); + if (host == null) { + GithubUtil.LOG.warn("Bad SSL host: " + url); + return false; + } + final String BACK_TO_SAFETY = "No, I don't trust"; final String TRUST = "Proceed anyway"; //int choice = Messages.showDialog("The security certificate of " + host + " is not trusted. Do you want to proceed anyway?", diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUrlUtil.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUrlUtil.java index c208e4db0ec1..c93f648d0728 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUrlUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUrlUtil.java @@ -16,6 +16,8 @@ package org.jetbrains.plugins.github.util; import com.intellij.openapi.util.text.StringUtil; +import org.apache.commons.httpclient.URI; +import org.apache.commons.httpclient.URIException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.github.api.GithubApiUtil; @@ -71,6 +73,19 @@ public class GithubUrlUtil { return "https://" + getGitHostWithoutProtocol(); } + /** + * E.g.: https://github.com/suffix/ -> github.com + */ + @Nullable + public static String getHostFromUrl(@NotNull String url) { + try { + return new URI(url, false).getHost(); + } + catch (URIException e) { + return null; + } + } + /** * E.g.: github.com * my.company.url