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

URL should handle lower-casing of protocol locale-independently

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 7u85, 8u66, 9
    • core-libs
    • b104
    • generic
    • generic
    • Verified

      According to the RFC, URL protocols are to be consumed case-insensitively, while a producer needs to use lowercase alphabetic characters, defined by the RFC as a-z. URL's with uppercase characters in the protocol are allowed as long as they are a-z / A-Z, e.g., FILE:///, Jar:/...

      Using some locales, e.g., turkish, consuming an upper-case protocol such as FILE will be lower-cased by the current URL implementation to "f\u0131le", which is illegal and will throw a MalformedURLException on most versions of Java:

           Locale.setDefault(new Locale("tr"));
           new URL("FILE:///tmp");

      The fix seems to be to consistently use String.toLowerCase(Locale.ENGLISH) to lower-case the protocol.

      Additionally enforcing lower-case across URL methods would allow using case-sensitive String.equals across the code, which avoids penalizing the common path.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: