From 3507b6b918a443bc5603b1a1f31b5157339198df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Enr=C3=ADquez?= Date: Tue, 24 Jan 2023 19:22:27 +0100 Subject: [PATCH] [#239][#249] Parse quoted git ls-files Problem: When a file name contains unusual characters, its output line in git ls-files is quoted and Xrefcheck parses the file name wrong. Solution: If a git ls-files output line starts with a double quote, use the String Read instance for parsing it. --- src/Xrefcheck/Scan.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Xrefcheck/Scan.hs b/src/Xrefcheck/Scan.hs index 2cdee8c1..444cd998 100644 --- a/src/Xrefcheck/Scan.hs +++ b/src/Xrefcheck/Scan.hs @@ -181,7 +181,7 @@ readDirectoryWith -> CanonicalPath -> IO [(CanonicalPath, a)] readDirectoryWith mode config scanner root = do - relativeFiles <- L.lines <$> getFiles + relativeFiles <- fmap filePath . L.lines <$> getFiles canonicalFiles <- mapM (root FilePath + filePath = \case + quoted@('\"' : _) -> fromMaybe quoted $ readMaybe quoted + unquoted -> unquoted + scanFile :: CanonicalPath -> IO (CanonicalPath, a) scanFile c = (c,) <$> scanner c