JackieJ / proxy-vole

Automatically exported from code.google.com/p/proxy-vole
0 stars 1 forks source link

Problem with url for PAC file #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For the differents Strategy (IE, Firefox, etc) the url is different 
(IE=file://... , FIREFOX=file:///...) and the UrlPacScriptSource class evaluate 
"file:/".
This do that not parse de PAC file.

Original issue reported on code.google.com by martin.j...@gmail.com on 6 Dec 2010 at 3:49

GoogleCodeExporter commented 8 years ago
I attach one solution

Original comment by martin.j...@gmail.com on 6 Dec 2010 at 7:28

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,
This is known problem. And I do not know about a clear way to solve this.
The file URLs are handled differently and seem not to be clearly specified.
You will have a lot of confusion with this, particularly when you have an UNC 
name encoded in A URL: e.g. \\my_server\path\file.pac
Will give you a URL of this format

file:///my_server/path/file.pac or file:////my_server/path/file.pac

So you never know exactly how many slashes belong to the protocol and how many 
to the  location.

I will review your patch and test it and if all looks good integrate it.
Thanks for reporting this and thanks for taking your time to provide a patch.

Have fun,
- Rossi

Original comment by rosstaus...@googlemail.com on 11 Dec 2010 at 12:12

GoogleCodeExporter commented 8 years ago
With IE8 there is also a Problem with reading PAC via HTTP-Protokol. When i do 
the standard way: ProxySelector lcMyProxySelector = 
proxySearch.getProxySelector();
lcMyProxySelector is null. I had to use a workaround:
Win32IESettings ieSettings = new IEProxySearchStrategy().readSettings();
UrlPacScriptSource lcPSS = new 
UrlPacScriptSource(ieSettings.getAutoConfigUrl());
lcMyProxySelector = new PacProxySelector(lcPSS);
Then lcMyProxySelector can be set to default.

Original comment by rgrannem...@googlemail.com on 26 Aug 2011 at 1:00

GoogleCodeExporter commented 8 years ago
I noticed the same thing. Setting a URL to a pac file in Internet Explorer 9, 
via Internet Options > Connections > LAN Settings > Use automatic 
configurations script:  Expects a file: URL to have 2 slashes like this 
"file://C:/sample.pac"

But when this is parsed inside of IEProxySearchStrategy.createPacSelector the 
URL is unrecognized unless it has the more proper 3 slashes like this: 
"file:///C:/sample.pac"

ERROR: com.btr.proxy.selector.pac.UrlPacScriptSource - File reading error.
ERROR: com.btr.proxy.selector.pac.UrlPacScriptSource - Loading script failed.
ERROR: com.btr.proxy.selector.pac.JavaxPacScriptParser - JS evaluation error.
ERROR: com.btr.proxy.selector.pac.PacProxySelector - PAC resolving error.

Since this is really an IE problem of forcing you to use improperly formatted 
URL's 
http://en.wikipedia.org/wiki/File_URI_scheme

It seems a simple fix would be to patch the IE URL inside of the 
IEProxySearchStrategy class like this...

if (pacUrl != null && pacUrl.trim().length() > 0) {
    Logger.log(getClass(), LogLevel.TRACE, "IE uses script: "+pacUrl);

    // If the IE has a file URL and it only starts has 2 slashes, add a third so 
    // it can be properly converted to the URL class
    if(pacUrl.startsWith("file://") && !pacUrl.startsWith("file:///")) {
        pacUrl = "file:///" + pacUrl.substring(7);
    }

    return new PacProxySelector(new UrlPacScriptSource(pacUrl));
}

I tested the above code and it now works properly for me.

Original comment by awbra...@gmail.com on 1 Nov 2011 at 11:13

GoogleCodeExporter commented 8 years ago
Hi,
I really like your fix proposal. It is local to the IE code and will align the 
URLs to the common format.
I integrated this in the repository and also made a new release containing this.

Thanks for the good proposal,
- Rossi

Original comment by rosstaus...@googlemail.com on 2 Nov 2011 at 9:23