diff --git a/pkgs/racket-test-core/tests/racket/path.rktl b/pkgs/racket-test-core/tests/racket/path.rktl index 99a577d5f5..4166afd5f2 100644 --- a/pkgs/racket-test-core/tests/racket/path.rktl +++ b/pkgs/racket-test-core/tests/racket/path.rktl @@ -944,6 +944,8 @@ (test (bytes->path #"../") simplify-path (bytes->path #"../") #f) (test (bytes->path #"../") simplify-path (bytes->path #"..//") #f) (test (bytes->path #"../") simplify-path (bytes->path #"..//./") #f) + (test (bytes->path #"/x") simplify-path (bytes->path #"/../../x") #f) + (test (bytes->path #"/") simplify-path (bytes->path #"/x/../..") #f) (test (bytes->path #"x/") path->directory-path (bytes->path #"x")) (test (bytes->path #"x/") path->directory-path (bytes->path #"x/")) (test (bytes->path #"x/./") path->directory-path (bytes->path #"x/.")) diff --git a/racket/src/cs/schemified/io.scm b/racket/src/cs/schemified/io.scm index f986bdf569..6dca0c65ee 100644 --- a/racket/src/cs/schemified/io.scm +++ b/racket/src/cs/schemified/io.scm @@ -25003,11 +25003,20 @@ accum_0) (if (eq? 'up (car l_1)) (if (pair? accum_0) - (let ((app_0 - (cdr l_1))) + (if (if (null? + (cdr + accum_0)) + (1/absolute-path? + (car accum_0)) + #f) (loop_0 - app_0 - (cdr accum_0))) + (cdr l_1) + accum_0) + (let ((app_0 + (cdr l_1))) + (loop_0 + app_0 + (cdr accum_0)))) (cons 'up (loop_0 diff --git a/racket/src/io/path/simplify-nofs.rkt b/racket/src/io/path/simplify-nofs.rkt index 61c4060b5e..504073bd08 100644 --- a/racket/src/io/path/simplify-nofs.rkt +++ b/racket/src/io/path/simplify-nofs.rkt @@ -8,7 +8,8 @@ "directory-path.rkt" "complete.rkt" "parameter.rkt" - "windows.rkt") + "windows.rkt" + "relativity.rkt") (provide simplify-path-syntactically) @@ -52,7 +53,13 @@ [(eq? 'up (car l)) (cond [(pair? accum) - (loop (cdr l) (cdr accum))] + (cond + [(and (null? (cdr accum)) + (absolute-path? (car accum))) + ;; for 'up at root, just keep the root + (loop (cdr l) accum)] + [else + (loop (cdr l) (cdr accum))])] [else (cons 'up (loop (cdr l) null))])] [else (loop (cdr l) (cons (car l) accum))])))