PublicSuffixMatcher.java (httpcomponents-client-4.5.8-src) | : | PublicSuffixMatcher.java (httpcomponents-client-4.5.9-src) | ||
---|---|---|---|---|
skipping to change at line 145 | skipping to change at line 145 | |||
* | * | |||
* @since 4.5 | * @since 4.5 | |||
*/ | */ | |||
public String getDomainRoot(final String domain, final DomainType expectedTy pe) { | public String getDomainRoot(final String domain, final DomainType expectedTy pe) { | |||
if (domain == null) { | if (domain == null) { | |||
return null; | return null; | |||
} | } | |||
if (domain.startsWith(".")) { | if (domain.startsWith(".")) { | |||
return null; | return null; | |||
} | } | |||
String domainName = null; | final String normalized = domain.toLowerCase(Locale.ROOT); | |||
String segment = domain.toLowerCase(Locale.ROOT); | String segment = normalized; | |||
String result = null; | ||||
while (segment != null) { | while (segment != null) { | |||
// An exception rule takes priority over any other matching rule. | // An exception rule takes priority over any other matching rule. | |||
if (hasException(IDN.toUnicode(segment), expectedType)) { | final String key = IDN.toUnicode(segment); | |||
if (hasException(key, expectedType)) { | ||||
return segment; | return segment; | |||
} | } | |||
if (hasRule(key, expectedType)) { | ||||
if (hasRule(IDN.toUnicode(segment), expectedType)) { | return result; | |||
break; | ||||
} | } | |||
final int nextdot = segment.indexOf('.'); | final int nextdot = segment.indexOf('.'); | |||
final String nextSegment = nextdot != -1 ? segment.substring(nextdot + 1) : null; | final String nextSegment = nextdot != -1 ? segment.substring(nextdot + 1) : null; | |||
if (nextSegment != null) { | if (nextSegment != null) { | |||
if (hasRule("*." + IDN.toUnicode(nextSegment), expectedType)) { | if (hasRule("*." + IDN.toUnicode(nextSegment), expectedType)) { | |||
break; | return result; | |||
} | } | |||
} | } | |||
if (nextdot != -1) { | result = segment; | |||
domainName = segment; | ||||
} | ||||
segment = nextSegment; | segment = nextSegment; | |||
} | } | |||
return domainName; | return normalized; | |||
} | } | |||
/** | /** | |||
* Tests whether the given domain matches any of entry from the public suffi x list. | * Tests whether the given domain matches any of entry from the public suffi x list. | |||
*/ | */ | |||
public boolean matches(final String domain) { | public boolean matches(final String domain) { | |||
return matches(domain, null); | return matches(domain, null); | |||
} | } | |||
/** | /** | |||
End of changes. 7 change blocks. | ||||
12 lines changed or deleted | 10 lines changed or added |