From 04c1c15d899cb017b4a3ad4ce0088799c6c49364 Mon Sep 17 00:00:00 2001 From: Ben Greenman Date: Wed, 28 Jun 2017 10:19:50 -0400 Subject: [PATCH] bug: add guard against string-paths in 'find-relative-path' Add guard, if first argument to `find-relative-path` is not a path, then don't call `path-convention-type` on it. Thanks to Jack Firth for reporting: https://github.com/racket/rackunit/pull/46 --- pkgs/racket-test-core/tests/racket/pathlib.rktl | 1 + racket/collects/racket/path.rkt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/racket-test-core/tests/racket/pathlib.rktl b/pkgs/racket-test-core/tests/racket/pathlib.rktl index cff8d6c61e..daf95fdf76 100644 --- a/pkgs/racket-test-core/tests/racket/pathlib.rktl +++ b/pkgs/racket-test-core/tests/racket/pathlib.rktl @@ -86,6 +86,7 @@ #:more-than-root? #t)) (test (bytes->path #"../.." 'unix) 'find-relative-path (find-relative-path (bytes->path #"/r/c" 'unix) (bytes->path #"/" 'unix) #:more-than-root? #t)) +(test "/" 'find-relative-path (find-relative-path "/" "/" #:more-than-root? #t)) (test (bytes->path #"..\\b\\a" 'windows) find-relative-path (bytes->path #"C:/r/c" 'windows) (bytes->path #"c:/R/b/a" 'windows)) (test (bytes->path #"..\\b\\a" 'windows) find-relative-path (bytes->path #"C:/r/c" 'windows) (bytes->path #"c:/r/b/a" 'windows)) diff --git a/racket/collects/racket/path.rkt b/racket/collects/racket/path.rkt index 50ff6a05c4..725a73113e 100644 --- a/racket/collects/racket/path.rkt +++ b/racket/collects/racket/path.rkt @@ -134,7 +134,9 @@ p))]) (if (and (equal? (normalize (car dir)) (normalize (car file))) (or (not more-than-root?) - (not (eq? 'unix (path-convention-type directory))) + (not (eq? 'unix (if (string? directory) + (system-path-convention-type) + (path-convention-type directory)))) (null? (cdr dir)) (null? (cdr file)) (equal? (normalize (cadr dir)) (normalize (cadr file)))))