diff options
author | nand <git@nand.wakku.to> | 2014-02-09 01:11:13 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2014-02-15 12:44:57 +0100 |
commit | c28cbcf859d303483ed6def8a113ed3b60375eb7 (patch) | |
tree | 0587a551c8fa40fbdfd8df3613739d807e0d8a54 /src/Plugins/Monitors | |
parent | 88ccc6fa73aaad98ee39587d16a2998b945869f1 (diff) | |
download | xmobar-c28cbcf859d303483ed6def8a113ed3b60375eb7.tar.gz xmobar-c28cbcf859d303483ed6def8a113ed3b60375eb7.tar.bz2 |
Fix runaway memory leak when expanding invalid tags, and remove error
Don't recursively parse on the case of an error. Also, in the case of an
error, instead of replacing by an error message, replace by the tag
itself to prevent mangling strings that legitimately include < and >
characters, for example song titles when using the MPD plugin.
I'm not sure how to handle this better. Honestly, I would like to remove
the recursive parsing altogether but this works for now. Consider filing
an issue for a proper resolution of this. I don't want rogue tags
expanding themselves in my song titles.
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r-- | src/Plugins/Monitors/Common.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Plugins/Monitors/Common.hs b/src/Plugins/Monitors/Common.hs index a8b6542..9ebe828 100644 --- a/src/Plugins/Monitors/Common.hs +++ b/src/Plugins/Monitors/Common.hs @@ -337,10 +337,10 @@ combine :: Map.Map String String -> [(String, String, String)] -> Monitor String combine _ [] = return [] combine m ((s,ts,ss):xs) = do next <- combine m xs - let str = Map.findWithDefault err ts m - err = "<" ++ ts ++ " not found!>" - nstr <- parseTemplate' str m - return $ s ++ (if null nstr then str else nstr) ++ ss ++ next + str <- case Map.lookup ts m of + Nothing -> return $ "<" ++ ts ++ ">" + Just r -> let f "" = r; f n = n; in fmap f $ parseTemplate' r m + return $ s ++ str ++ ss ++ next -- $strings |