Skip to content

Commit 69141cb

Browse files
committed
Also validate in pstr pattern
1 parent 1c7f639 commit 69141cb

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

System/OsPath/Posix.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pstr =
2222
lift ps
2323
, quotePat = \s -> do
2424
osp' <- either (fail . show) pure . encodeWith (mkUTF8 ErrorOnCodingFailure) $ s
25+
when (not $ isValid osp') $ fail ("filepath not valid: " ++ show osp')
2526
[p|((==) osp' -> True)|]
2627
, quoteType = \_ ->
2728
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a type)"

System/OsPath/Windows.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pstr =
2323
lift ps
2424
, quotePat = \s -> do
2525
osp' <- either (fail . show) pure . encodeWith (mkUTF16le ErrorOnCodingFailure) $ s
26+
when (not $ isValid osp') $ fail ("filepath not valid: " ++ show osp')
2627
[p|((==) osp' -> True)|]
2728
, quoteType = \_ ->
2829
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a type)"

0 commit comments

Comments
 (0)