Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6338951

java.net.URI now accepts "http://-a"

    XMLWordPrintable

Details

    • b65
    • generic
    • generic

    Description

      java.net.URI has been updated in Mustang to support IRIs (see RFC 3986). However, as a side-effect of that work, it now accepts certain ordinary ASCII URIs that were previously illegal and that are not valid DNS names. For example, "http://-a" is now valid even though it is not a valid DNS name because it begins with a hyphen.

      It seems unclear to me from RFC 3986 whether URIs are now supposed to be legal even if they are not valid DNS names. The RFC says:
        "This specification does not mandate a particular registered name
         lookup technology and therefore does not restrict the syntax of reg-
         name beyond what is necessary for interoperability. Instead, it
         delegates the issue of registered name syntax conformance to the
         operating system of each application performing URI resolution, and
         that operating system decides what it will allow for the purpose of
         host identification. [...] URI producers should use names
         that conform to the DNS syntax, even when use of DNS is not
         immediately apparent, and should limit these names to no more than
         255 characters in length."

      This clearly says that URI producers should not try producing URIs like "http://-a", but it is much less clear as to whether a class such as java.net.URI should reject them. java.net.URI doesn't "perform URI resolution", so arguably it should defer syntax checking to whatever does.

      If it is decided that "http://-a" is indeed supposed to be accepted, then the specification of java.net.URI.getRawHost() must be updated so it no longer says that a hostname cannot begin or end with a hyphen.

      Attachments

        Activity

          People

            yuwangsunw Yujiang Wang (Inactive)
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: