markewiseman / proxy-vole

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

PAC evaluation fails when String.length is used #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce:

Use proxy vole with JDK 6 default JS engine and PAC file that uses String 
length property, i.e:

function FindProxyForURL(url, host)
{
  var ip = myIpAddress();
  if( ip==null || ip.length<1){
    return "DIRECT";
  }else{
    return "PROXY my.proxy.com:8080";
  }
}

Expected behavior: 
PAC script should evaluate without problems

Actual behavior: 
exception thrown on "ip.length<1" evaluation

Error cause:
PacScriptMethods.myIpAddress() returns Java String, which from JS perspective 
has length() function but does not have length property (myIpAddress().length() 
returns expected value, while myIpAddress().length returns a function, thus 
resulting in "NaN cannot be converted to int" error when comparing it with a 
number)

Version affected: 20121203

Suggested fix:

For JDK built-in JS engine, modify setupEngine() method fragment that is 
registering functions available to PAC script, so that for every function 
returning String, it's result would be converted to JavaScript String (see 
attached diff).

Original issue reported on code.google.com by plimano...@gmail.com on 8 Jan 2013 at 12:48

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,
I have now found the time to look into this. The patch that you have provided 
was very helpfull. I have integrated something similar into proxy-vole now. 
The changes are already in the repository and will be shipped with the next 
version.

Thanks for finding this out. 

- Rossi

Original comment by rosstaus...@googlemail.com on 24 Jan 2013 at 9:44

GoogleCodeExporter commented 9 years ago
Hi,

I'm glad I could help.
Btw - I have found your nice lib while trying to make URLConns made by
stdalone app work from within big bank intranet. I love the lib - it's easy
to use and saved me a lot of time..

Good job!

Thanks and regards,
Pawel Limanowka
24 sty 2013 22:44, <proxy-vole@googlecode.com> napisał(a):

Original comment by plimano...@gmail.com on 28 Jan 2013 at 4:39