MarkusBernhardt / proxy-vole

Proxy Vole is a Java library to auto detect the platform network proxy settings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proxy-vole not able to parse PAC file when space in IP address in pac java script

Maxoudela opened this issue · comments

commented

Opening a new issue since I cannot open back issue #25

Consider the following declaration in the proxy-pac file :
isInNet(myIpAddress(), "10.112.190.0", "255.255.255.0 ")
A trailing space has been added after the last 0. We will then go into the isInNet method of PacScriptMethods, then in parseIpAddressToLong :


private long parseIpAddressToLong(String address) {
		long result = 0;
		String[] parts = address.split("\\.");
		long shift = 24;
		for (String part : parts) {
			long lpart = Long.parseLong(part);

			result |= (lpart << shift);
			shift -= 8;
		}
		return result;
	}

The parseLong will fail when it will try to parse the "0 " with the trailing space. I recommand doing a "part.trim()" in order to prevent such cases.
I can make a PR if you want.

Modifying the test2.pac to :

// Test comments in scripts

function FindProxyForURL(url, host) {

  /*
   * This is a multiline comment
   */
if (isInNet(myIpAddress(), "10.55.159.0", "255.255.255.0 ")){
  return "DIRECT"; // This returns always DIRECT
}
}

and running testCommentsInScript() test in JavaxPacScriptParserTest demonstrates the issue.

Markus doesn't answer any issues or pull requests here for nearly a year now. This project is dead, I think. Unfortunately. :-(

commented

Thanks I'll have a look and provide a PR on your fork if necessary then!

commented

I do confirm that this issue has been fixed in https://github.com/akuhtz/proxy-vole/
Switching to this fork from now on, closing issue.