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

Path.relativize returns incorrect result if path contains ".."

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_02"
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      This issue is related to bug #6925169.

      The relativize method doesn't handle ".." correctly.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run attached testcase.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.nio.file.Path;

      public class Test {

          public static void main(String[] args) {
              Path p1 = new File("/a/b/..").toPath();
              Path p2 = new File("/a").toPath();
              Path q = new File("/c/d").toPath();
              Path first = p1.relativize(q).normalize();
              Path second = p2.relativize(q).normalize();
              assert (first.equals(second)) : "first: " + first + ", second: " + second;
          }
      }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: