Skip to content

Politeness keys do not collapse IDN host spellings (unicode vs punycode) #2145

Description

@abhinav-phi

Follow-up from #2122 (review by rzo1).

okhttp punycodes the host when it parses a URL: IDN.toASCII("ExAmpleé.org") gives xn--exampl-gva.org. URLUtil.getCanonicalHost (introduced in #2122 for politeness queues and the robots.txt cache) lowercases and percent-decodes the host but does not punycode it, so the Unicode and punycode spellings of one server still get separate politeness queues and separate robots.txt cache entries:

  • http://ExAmpleé.org/ → host ExAmpleé.org → key examplé.org
  • http://xn--exampl-gva.org/ → key xn--exampl-gva.org

Suggested fix: apply IDN.toASCII in getCanonicalHost (falling back to the raw host when the label is not a valid IDN), so both spellings collapse the way okhttp collapses them at connect time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions