google / guava

Google core libraries for Java
Apache License 2.0
50.1k stars 10.87k forks source link

Guava's InternetDomainName API exception #1796

Closed gissuebot closed 9 years ago

gissuebot commented 9 years ago

Original issue created by kapoorvinny on 2014-07-04 at 12:22 PM


Guava's InternetDomainName API gives exception while computing "topPrivateDomain" from websites like "gov.uk'. It works fine for "nhs.uk".

I guess it needs to add "gov.uk" in excluded set.

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-04 at 12:28 PM


Forgot to add logs:

code: InternetDomainName idn = InternetDomainName.from(site);

if (idn.hasPublicSuffix()) {     tld = idn.publicSuffix().name();

if (!idn.isTopPrivateDomain()) {         site = idn.topPrivateDomain().name(); }

}

Exception: java.lang.IllegalStateException: Not under a public suffix: gov.uk

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-04 at 02:03 PM


Few more examples of failing urls. These are with ports.

graph.facebook.com:443 fbcdn-profile-a-akamaihd.net:443 gsp10-ssl.apple.com:443 fbcdn-photos-f-a-akamaihd.net:443

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-07-07 at 04:02 PM


(No comment entered for this change.)


Owner: cberry@google.com Labels: Package-Net

gissuebot commented 9 years ago

Original comment posted by cberry@google.com on 2014-07-07 at 04:07 PM


The Mozilla public suffix list has been updated to handle this case. When we release a version of Guava incorporating that update, this will work properly.

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-07-07 at 04:11 PM


(No comment entered for this change.)


Status: Fixed Labels: Milestone-Release18

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-08 at 05:01 PM


Thanks for a quick fix. Can i know when will be 18.0 release. Also can i test it with 18.0-snapshot?

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-07-08 at 05:08 PM


I think you should be able to test it with 18.0-SNAPSHOT. It looks like we last updated the public suffix list on June 29: https://github.com/google/guava/commit/2929b111d677c539cb03a4f22b95cbc8944ce3fa

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-08 at 08:28 PM


I raised this bug on 4th July. Does that mean its not fixed if the last related change is made 9 days ago. Kindly explain if i have misunderstood it.

gissuebot commented 9 years ago

Original comment posted by cberry@google.com on 2014-07-08 at 08:31 PM


The fix was already in the pipeline when you filed the bug.

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-08 at 08:40 PM


Many thanks for the quick reply. Shall i use the following to test it. <dependency>     <groupId>com.google.guava</groupId>     <artifactId>guava</artifactId>     <version>18.0-SNAPSHOT</version> </dependency>

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-07-15 at 10:42 AM


Can you kindly give me an idea when will there be 18.0 release. Also please answer how can i test the above issue.

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-07-15 at 05:42 PM


No date for 18.0, though I'd like to get a release candidate of it out this week. And yes, you should be able to test it with 18.0-SNAPSHOT (you'll have to build it yourself).

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-08-01 at 03:48 PM


Do you have the date for 18.0 release yet. Also i have been trying to build the latest source following instructions on https://code.google.com/p/guava-libraries/wiki/ContributorSetUp

but have failures while installing or building.

Can you suggest how to build it. I really want to confirm the fix and use it.

gissuebot commented 9 years ago

Original comment posted by vinny.ka...@wandera.com on 2014-08-15 at 02:29 PM


I have tried guava-18.0-rc1.jar and used to following code to test it:

String site = "gov.uk"; InternetDomainName idn = InternetDomainName.from(site);

if (idn.hasPublicSuffix()) {     String tld = idn.publicSuffix().toString();

if (!idn.isTopPrivateDomain()) {
    site = idn.topPrivateDomain().toString();
}

}

Its still failing and throwing exception : java.lang.IllegalStateException: Not under a public suffix: gov.uk

Am i missing anything?

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-08-19 at 05:36 PM


Hmm. It looks like this is just intended behavior, as "gov.uk" is itself a public suffix and as such not under a public suffix.

gissuebot commented 9 years ago

Original comment posted by kapoorvinny on 2014-08-19 at 05:40 PM


But https://www.gov.uk/ is the valid web URL like http://www.nhs.uk.

So why "gov.uk" behaves differently than "nhs.uk"

gissuebot commented 9 years ago

Original comment posted by cgdecker@google.com on 2014-08-19 at 05:46 PM


Both "gov.uk" and "nhs.uk" are in the public suffix list, and both behave the same in InternetDomainName from what I can tell (testing in 18.0-rc1). Both return true for isPublicSuffix() and both throw IllegalStateException from topPrivateDomain().

gissuebot commented 9 years ago

Original comment posted by cberry@google.com on 2014-08-19 at 05:47 PM


gov.uk and nhs.uk should both behave the same way. Are you seeing something different?