Genormaliseerde paden in keystore.
This commit is contained in:
+32
-2
@@ -9,6 +9,10 @@
|
||||
int-value
|
||||
string-value
|
||||
split-addresses
|
||||
normalized-relpath-string
|
||||
normalized-relpath->path
|
||||
normalize-relpath-string
|
||||
legacy-backslash-relpath-string
|
||||
relpath-string
|
||||
filesystem-path
|
||||
flac-path?
|
||||
@@ -70,8 +74,34 @@
|
||||
[else (raise-argument-error 'filesystem-path "path-string? or path?" p)]))
|
||||
(simple-form-path (string->path (windows-extended-path-string s))))
|
||||
|
||||
(define (relpath-string base p)
|
||||
(path->string (find-relative-path (filesystem-path base) (filesystem-path p))))
|
||||
(define (replace-char s from to)
|
||||
(list->string
|
||||
(for/list ([ch (in-string s)])
|
||||
(if (char=? ch from) to ch))))
|
||||
|
||||
(define (normalize-relpath-string s)
|
||||
(define normalized (replace-char s #\\ #\/))
|
||||
(when (or (string=? normalized "")
|
||||
(regexp-match? #rx"^[A-Za-z]:" normalized)
|
||||
(regexp-match? #rx"^/" normalized)
|
||||
(regexp-match? #rx"(^|/)\\.\\.(/|$)" normalized))
|
||||
(raise-argument-error 'normalize-relpath-string "relative path without .." s))
|
||||
normalized)
|
||||
|
||||
(define (legacy-backslash-relpath-string relpath)
|
||||
(replace-char (normalize-relpath-string relpath) #\/ #\\))
|
||||
|
||||
(define (normalized-relpath-string base p)
|
||||
(normalize-relpath-string
|
||||
(path->string (find-relative-path (filesystem-path base) (filesystem-path p)))))
|
||||
|
||||
(define relpath-string normalized-relpath-string)
|
||||
|
||||
(define (normalized-relpath->path relpath)
|
||||
(define parts (regexp-split #rx"/+" (normalize-relpath-string relpath)))
|
||||
(when (ormap (lambda (part) (or (string=? part "") (string=? part "."))) parts)
|
||||
(raise-argument-error 'normalized-relpath->path "relative normalized path" relpath))
|
||||
(apply build-path parts))
|
||||
|
||||
(define (extension-ci=? p ext)
|
||||
(let-values ([(base name dir?) (split-path p)])
|
||||
|
||||
Reference in New Issue
Block a user