From 3e9e1cb9d300e13109206496d825351c4f41cc1c Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sun, 10 May 2020 19:43:56 +0530 Subject: Fix crashes/busy looping happening via index Right now, with the `StdinReader` plugin enabled - you can crash/cause busy looping of xmobar if the following html file is opened: ``` hello <fn=1>string</fn> ``` More details about this bug is here: https://github.com/jaor/xmobar/issues/442#issuecomment-625706001 This MR also fixes another bug which produces a crash in xmobar if you pass non integer items between fn: --- src/Xmobar/X11/Parsers.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Xmobar/X11/Parsers.hs') diff --git a/src/Xmobar/X11/Parsers.hs b/src/Xmobar/X11/Parsers.hs index 7fa42d7..4c8a130 100644 --- a/src/Xmobar/X11/Parsers.hs +++ b/src/Xmobar/X11/Parsers.hs @@ -21,6 +21,7 @@ import Xmobar.X11.Actions import Control.Monad (guard, mzero) import Text.ParserCombinators.Parsec +import Text.Read (readMaybe) import Graphics.X11.Types (Button) data Widget = Icon String | Text String @@ -138,7 +139,7 @@ fontParser :: ColorString -> Maybe [Action] -> Parser [(Widget, ColorString, FontIndex, Maybe [Action])] fontParser c a = do f <- between (string "") colors - s <- manyTill (allParsers c (read f) a) (try $ string "") + s <- manyTill (allParsers c (maybe 0 id $ readMaybe f) a) (try $ string "") return (concat s) -- | Parses a color specification (hex or named) -- cgit v1.2.3