From bb9c75f1fa5bd18e03063ae25a17fe7498e57136 Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Mon, 11 Nov 2024 12:53:15 +0900 Subject: [PATCH 1/2] Ensure generated siName does not contain newlines --- src/System/MemInfo/Proc.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/System/MemInfo/Proc.hs b/src/System/MemInfo/Proc.hs index 55c85c0..73a3bd1 100644 --- a/src/System/MemInfo/Proc.hs +++ b/src/System/MemInfo/Proc.hs @@ -55,7 +55,8 @@ data StatusInfo = StatusInfo instance Validity StatusInfo where validate StatusInfo {siName, siParent} = let name' = Text.strip siName - nameOk = Text.length name' > 0 && siName == name' + noNewlines = not $ Text.elem '\n' siName + nameOk = noNewlines && Text.length name' > 0 && siName == name' in mconcat [ check nameOk "the process name" , delve "the process ID" $ toInteger siParent From def1a73e36f52432ff922a50cab58ca67570a8ca Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Mon, 11 Nov 2024 13:06:20 +0900 Subject: [PATCH 2/2] Prefer Text.any as Text.elem does not available with GHC 8.10.7 --- src/System/MemInfo/Proc.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System/MemInfo/Proc.hs b/src/System/MemInfo/Proc.hs index 73a3bd1..6be4101 100644 --- a/src/System/MemInfo/Proc.hs +++ b/src/System/MemInfo/Proc.hs @@ -55,7 +55,7 @@ data StatusInfo = StatusInfo instance Validity StatusInfo where validate StatusInfo {siName, siParent} = let name' = Text.strip siName - noNewlines = not $ Text.elem '\n' siName + noNewlines = not $ Text.any (== '\n') siName nameOk = noNewlines && Text.length name' > 0 && siName == name' in mconcat [ check nameOk "the process name"