Merge "Don\'t pass URL path and username/password to PAC scripts" into klp-dev
am: af0b4466ff
* commit 'af0b4466ffe2ed09b288014d1d3a9ed308fe3c76':
Don't pass URL path and username/password to PAC scripts
Change-Id: I8a49a29ed1999ab811d3306dc46769d83c05244e
This commit is contained in:
@@ -31,6 +31,7 @@ import java.net.Proxy.Type;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,15 @@ public class PacProxySelector extends ProxySelector {
|
||||
String response = null;
|
||||
String urlString;
|
||||
try {
|
||||
// Strip path and username/password from URI so it's not visible to PAC script. The
|
||||
// path often contains credentials the app does not want exposed to a potentially
|
||||
// malicious PAC script.
|
||||
if (!"http".equalsIgnoreCase(uri.getScheme())) {
|
||||
uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), "/", null, null);
|
||||
}
|
||||
urlString = uri.toURL().toString();
|
||||
} catch (URISyntaxException e) {
|
||||
urlString = uri.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
urlString = uri.getHost();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user