Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2016-10-13 11:46:49 -0400
committerDani Megert2016-10-15 10:04:57 -0400
commita4fb61b98bec0b2ef52afbe248f21b0195781dbf (patch)
treec7dd90d9bc25bf8846ad98161b51dd739cadd65e
parentb5c052a00231a41f5cf4161f556d2cf99cb740cf (diff)
downloadeclipse.platform.team-a4fb61b98bec0b2ef52afbe248f21b0195781dbf.tar.gz
eclipse.platform.team-a4fb61b98bec0b2ef52afbe248f21b0195781dbf.tar.xz
eclipse.platform.team-a4fb61b98bec0b2ef52afbe248f21b0195781dbf.zip
Bug 505906: UnixProxyProvider's support for no_proxy environmentY20161018-1100I20161018-0800
variable is non-standard Change-Id: I501d19073526f796d05892f2557ed63f4f59cf4a Signed-off-by: Markus Keller <markus_keller@ch.ibm.com>
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java7
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/StringUtil.java6
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java8
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java4
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java29
5 files changed, 38 insertions, 16 deletions
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
index 981b4906d..34a5f8c69 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
@@ -333,17 +333,12 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
String[] filters = getNonProxiedHosts();
for (int i = 0; i < filters.length; i++) {
String filter = filters[i];
- if (matchesFilter(uri.getHost(), filter))
+ if (StringUtil.hostMatchesFilter(uri.getHost(), filter))
return true;
}
return false;
}
- private boolean matchesFilter(String host, String filter) {
- StringMatcher matcher = new StringMatcher(filter, true, false);
- return matcher.match(host);
- }
-
/* (non-Javadoc)
* @see org.eclipse.net.core.IProxyManager#getProxyDataForHost(java.lang.String, java.lang.String)
*/
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/StringUtil.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/StringUtil.java
index 5746f2abd..71a2d3d50 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/StringUtil.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/StringUtil.java
@@ -100,4 +100,10 @@ public class StringUtil {
return buffer.toString();
}
+ public static boolean hostMatchesFilter(String host, String filter) {
+ String suffixMatchingFilter = "*" + filter; //$NON-NLS-1$
+ StringMatcher matcher = new StringMatcher(suffixMatchingFilter, true, false);
+ return matcher.match(host);
+ }
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
index 572c90275..9faffce49 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
@@ -23,7 +23,6 @@ import org.eclipse.core.internal.net.AbstractProxyProvider;
import org.eclipse.core.internal.net.Activator;
import org.eclipse.core.internal.net.Policy;
import org.eclipse.core.internal.net.ProxyData;
-import org.eclipse.core.internal.net.StringMatcher;
import org.eclipse.core.internal.net.StringUtil;
import org.eclipse.core.net.proxy.IProxyData;
@@ -56,7 +55,7 @@ public class UnixProxyProvider extends AbstractProxyProvider {
if (nonProxyHosts != null) {
String host = uri.getHost();
for (int npIndex = 0; npIndex < nonProxyHosts.length; npIndex++) {
- if (matchesFilter(host, nonProxyHosts[npIndex])) {
+ if (StringUtil.hostMatchesFilter(host, nonProxyHosts[npIndex])) {
return new IProxyData[0];
}
}
@@ -270,11 +269,6 @@ public class UnixProxyProvider extends AbstractProxyProvider {
System.out.println(i + ": " + strs[i]); //$NON-NLS-1$
}
- private boolean matchesFilter(String host, String filter) {
- StringMatcher matcher = new StringMatcher(filter, true, false);
- return matcher.match(host);
- }
-
protected static native void gconfInit();
protected static native ProxyData getGConfProxyInfo(String protocol);
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
index 98e8255e7..1a960d8e8 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
@@ -13,7 +13,6 @@ package org.eclipse.core.internal.net.proxy.win32.winhttp;
import java.net.URI;
-import org.eclipse.core.internal.net.StringMatcher;
import org.eclipse.core.internal.net.StringUtil;
/**
@@ -68,8 +67,7 @@ public class ProxyBypass {
private boolean isInBypassList(String host) {
for (int i = 0; i < proxyBypassEntries.length; i++) {
String entry = proxyBypassEntries[i];
- StringMatcher matcher = new StringMatcher(entry, true, false);
- if (matcher.match(host)) {
+ if (StringUtil.hostMatchesFilter(host, entry)) {
return true;
}
}
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
index 5a68028cc..6ae0f1daa 100644
--- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
+++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
@@ -338,6 +338,35 @@ public class NetTest extends TestCase {
this.getProxyManager().setNonProxiedHosts(oldHosts);
}
+ public void testHostPatternBug505906() throws CoreException {
+ setDataTest(IProxyData.HTTP_PROXY_TYPE);
+ setDataTest(IProxyData.HTTPS_PROXY_TYPE);
+ setDataTest(IProxyData.SOCKS_PROXY_TYPE);
+
+ String[] oldHosts = this.getProxyManager().getNonProxiedHosts();
+ this.getProxyManager().setNonProxiedHosts(new String[] { "ignore.com" });
+
+ IProxyData[] allData = this.getProxyManager().getProxyDataForHost("ignore.com.randomhot.com");
+ assertEquals(3, allData.length);
+
+ IProxyData data = this.getProxyManager().getProxyDataForHost("ignore.com.randomhot.com", IProxyData.HTTP_PROXY_TYPE);
+ assertNotNull(data);
+
+ allData = this.getProxyManager().getProxyDataForHost("www.ignore.com");
+ assertEquals(0, allData.length);
+
+ data = this.getProxyManager().getProxyDataForHost("www.ignore.com", IProxyData.HTTP_PROXY_TYPE);
+ assertNull(data);
+
+ allData = this.getProxyManager().getProxyDataForHost("ignore.com");
+ assertEquals(0, allData.length);
+
+ data = this.getProxyManager().getProxyDataForHost("ignore.com", IProxyData.HTTP_PROXY_TYPE);
+ assertNull(data);
+
+ this.getProxyManager().setNonProxiedHosts(oldHosts);
+ }
+
public void testBug238796() throws CoreException {
setDataTest(IProxyData.HTTP_PROXY_TYPE);
setDataTest(IProxyData.HTTPS_PROXY_TYPE);

Back to the top