negative bytestring indices are bad; put a floor of 0 under them to preserve the original behaviour
commitcc4fa1ba76240c2b1daf24e9b46df8078bb7ee6b
authorjay groven <jgroven@lutsendata.com>
dateWed 13 Jun 2012, 21:16 (14 years ago)
parent733fe48
wai-extra/Network/Wai/Parse.hs+3−1
@@ -284,9 +284,11 @@ findBound :: S.ByteString -> S.ByteString -> Bound
284284findBound b bs = handleBreak $ Search.breakOn b bs
285285 where
286286 handleBreak (h, t)
287− | S.null t = go [S.length bs - S.length b..S.length bs - 1]
287+ | S.null t = go [lowBound..S.length bs - 1]
288288 | otherwise = FoundBound h $ S.drop (S.length b) t
289289
290+ lowBound = max 0 $ S.length bs - S.length b
291+
290292 go [] = NoBound
291293 go (i:is)
292294 | mismatch [0..S.length b - 1] [i..S.length bs - 1] = go is