Codebase list haskell-xss-sanitize / 5fcc4f4
http-client: patch to ignore malformed headers Sean Whitton 4 years ago
3 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 haskell-http-client (0.5.13.1-3) unstable; urgency=medium
1
2 * Backport upstream commit 503d88f0f165453c295f530d74f27f8f689ace2d as
3 ignore-malformed-headers.diff (Closes: #931715).
4
5 -- Sean Whitton <spwhitton@spwhitton.name> Tue, 09 Jul 2019 19:55:33 +0100
6
07 haskell-http-client (0.5.13.1-2) unstable; urgency=medium
18
29 * Remove build dependency on libghc-text-dev (provided by ghc-8.4.3)
0 Backported from upstream commit
1 503d88f0f165453c295f530d74f27f8f689ace2d. See #931715.
2
3 --- a/Network/HTTP/Client/Headers.hs
4 +++ b/Network/HTTP/Client/Headers.hs
5 @@ -84,13 +84,20 @@ parseStatusHeaders conn timeout' cont
6 if S.null line
7 then return $ front []
8 else do
9 - header <- parseHeader line
10 - parseHeaders (count + 1) $ front . (header:)
11 + mheader <- parseHeader line
12 + case mheader of
13 + Just header ->
14 + parseHeaders (count + 1) $ front . (header:)
15 + Nothing ->
16 + -- Unparseable header line; rather than throwing
17 + -- an exception, ignore it for robustness.
18 + parseHeaders count front
19
20 - parseHeader :: S.ByteString -> IO Header
21 + parseHeader :: S.ByteString -> IO (Maybe Header)
22 parseHeader bs = do
23 let (key, bs2) = S.break (== charColon) bs
24 - when (S.null bs2) $ throwHttp $ InvalidHeader bs
25 - return (CI.mk $! strip key, strip $! S.drop 1 bs2)
26 + if S.null bs2
27 + then return Nothing
28 + else return (Just (CI.mk $! strip key, strip $! S.drop 1 bs2))
29
30 strip = S.dropWhile (== charSpace) . fst . S.spanEnd (== charSpace)
00 disable-external-network-connection-test.diff
1 ignore-malformed-headers.diff