Skip to content

Commit fe235d4

Browse files
committed
Gracefully handle invalid paths in error/warning messages (#1561)
1 parent 0a52a85 commit fe235d4

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Bug fixes:
1717
[#1551](https://github.com/commercialhaskell/stack/issues/1551)
1818
- Properly redownload corrupted downloads with the correct file size.
1919
[Mailing list discussion](https://groups.google.com/d/msg/haskell-stack/iVGDG5OHYxs/FjUrR5JsDQAJ)
20-
20+
- Gracefully handle invalid paths in error/warning messages
21+
[#1561](https://github.com/commercialhaskell/stack/issues/1561)
2122

2223
## 1.0.0
2324

src/Stack/Build/Execute.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Control.Concurrent.Async (withAsync, wait)
2222
import Control.Concurrent.Execute
2323
import Control.Concurrent.MVar.Lifted
2424
import Control.Concurrent.STM
25-
import Control.Exception.Enclosed (catchIO, tryIO)
25+
import Control.Exception.Enclosed (catchIO)
2626
import Control.Exception.Lifted
2727
import Control.Monad (liftM, when, unless, void, join, filterM, (<=<))
2828
import Control.Monad.Catch (MonadCatch, MonadMask)
@@ -1338,7 +1338,7 @@ printBuildOutput excludeTHLoading makeAbsolute pkgDir level outH = void $
13381338
=$ CL.mapM_ (monadLoggerLog $(TH.location >>= liftLoc) "" level)
13391339

13401340
-- | Strip Template Haskell "Loading package" lines and making paths absolute.
1341-
mungeBuildOutput :: MonadIO m
1341+
mungeBuildOutput :: (MonadIO m, MonadThrow m)
13421342
=> Bool -- ^ exclude TH loading?
13431343
-> Bool -- ^ convert paths to absolute?
13441344
-> Path Abs Dir -- ^ package's root directory
@@ -1363,21 +1363,17 @@ mungeBuildOutput excludeTHLoading makeAbsolute pkgDir = void $
13631363
let (x, y) = T.break (== ':') bs
13641364
mabs <-
13651365
if isValidSuffix y
1366-
then do
1367-
efp <- liftIO $ tryIO $ resolveFile pkgDir (T.unpack x)
1368-
case efp of
1369-
Left _ -> return Nothing
1370-
Right fp -> return $ Just $ T.pack (toFilePath fp)
1366+
then fmap (T.pack . toFilePath) <$> resolveFileMaybe pkgDir (T.unpack $ T.strip x)
13711367
else return Nothing
13721368
case mabs of
13731369
Nothing -> return bs
13741370
Just fp -> return $ fp `T.append` y
13751371

13761372
-- | Match the line:column format at the end of lines
1377-
isValidSuffix = isRight . parseOnly (lineCol <* endOfInput)
1373+
isValidSuffix = isRight . parseOnly lineCol
13781374
lineCol = char ':' >> (decimal :: Parser Int)
13791375
>> char ':' >> (decimal :: Parser Int)
1380-
>> (string ":" <|> string ": Warning:")
1376+
>> char ':'
13811377
>> return ()
13821378

13831379
-- | Strip @\r@ characters from the byte vector. Used because Windows.

0 commit comments

Comments
 (0)