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

new URI(u.toString()).equals(u) does not hold with paths containing colons

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 7
    • core-libs

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      java.net.URI promises that new URI(u.toString()).equals(u), but doesn't escape colons in paths. A path in a URI reference without a slash will be treated as an absolute URL when it is re-parsed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Construct a URI reference with a path containing an unescaped colon and no leading slash. Round-trip it via a String and observe that it's different to the original URI.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      true
      ./a:b

      or

      a%3Ab


      ACTUAL -
      false
      a:b

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      URI orig = new URI(null, null, " /a:b " , null);
      URI u = new URI( " . " ).relativize(orig);
      System.out.println(new URI(u.toString()).equals(u));
      System.out.println(u);
      ---------- END SOURCE ----------

            dfuchs Daniel Fuchs
            webbuggrp Webbug Group
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: