[Mono-bugs] [Bug 42303][Nor] New - Path.GetFullPath () does not handle '.' and '..'

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 4 May 2003 09:23:04 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gfr@skynet.be.

http://bugzilla.ximian.com/show_bug.cgi?id=42303

--- shadow/42303	Sun May  4 09:23:04 2003
+++ shadow/42303.tmp.7285	Sun May  4 09:23:04 2003
@@ -0,0 +1,107 @@
+Bug#: 42303
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: Red Hat 9 + libgc,mono,mcs up-to-date from cvs
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gfr@skynet.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: Path.GetFullPath () does not handle '.' and '..'
+
+Description of Problem:
+
+When we call the method Path.GetFullPath () with a path like
+'/somepath/./subpart/../././subpart/.' the result are different
+than the microsoft result.
+
+In MS, we receive '/somepath/subpart'
+In Mono, we receive the given argument
+
+Steps to reproduce the problem:
+1. Create a file called Test5.cs with the following content
+
+>>> SOT >>>
+using System;
+using System.IO;
+                                                                          
+                                                  
+namespace Test5
+{
+  public class Test5
+  {
+    public static void Test (System.String Expanded, System.String Compacted)
+    {
+      System.String expanded  = Path.GetFullPath (Expanded);
+      System.String compacted = Path.GetFullPath (Compacted);
+                                                                          
+                                                  
+      if (expanded == compacted)
+      {
+        System.Console.Out.WriteLine ("Test success : expanded = compacted
+= '{0}'", expanded);
+      }
+      else
+      {
+        System.Console.Out.WriteLine ("Test fail    : expanded '{0}' and
+compacted = '{1}'", expanded, compacted);
+      }
+    }
+                                                                          
+                                                  
+    public static void Main ()
+    {
+      Test ("/root/././././././../root/././../root",            "/root"     );
+      Test ("c:/windows/././././././../windows/././../windows", "c:/windows");
+    }
+  }
+}
+>>> EOT >>>
+
+2. compile it with the command : mcs -target:exe -out:Test5.exe  Test5.cs 
+3. start it with the mono and the MS dotnet environment.
+
+Actual Results:
+
+- Under Microsoft dotnet :
+Test success : expanded = compacted = 'C:\root'
+Test success : expanded = compacted = 'c:\windows'
+
+- Under Mono on linux inside the root directory :
+est fail    : expanded '/root/././././././../root/././../root' and
+compacted = '/root'
+Test fail    : expanded
+'/root/c:/windows/././././././../windows/././../windows' and compacted =
+'/root/c:/windows'
+
+
+Expected Results:
+
+- Under Microsoft dotnet :
+Test success : expanded = compacted = 'C:\root'
+Test success : expanded = compacted = 'c:\windows'
+
+- Under Mono on linux  inside the root directory :
+Test success : expanded = compacted = '/root'
+Test sucesss : expanded = compacted = '/root/c:/windows'
+
+How often does this happen? 
+
+Each time.
+
+Additional Information:
+
+This problems is only depending to the fact that the microsoft
+dotnet runtime make the path resolution where '/./' become '/'
+and '/dir/../dir/' become '/dir/'
+
+The test under MS runtime has been made with one 1.0 version
+
+Best regards to all
+Gilles