html-conduit 1.1.1.1 → 1.1.1.2
raw patch · 5 files changed
+20/−25 lines, 5 filesdep ~tagstream-conduitPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: tagstream-conduit
API changes (from Hackage documentation)
Files
- ChangeLog.md +3/−0
- README.md +4/−0
- Text/HTML/DOM.hs +2/−22
- html-conduit.cabal +3/−3
- test/main.hs +8/−0
+ ChangeLog.md view
@@ -0,0 +1,3 @@+## 1.1.1.2++* Fix a bug with double-unescaping of entities
+ README.md view
@@ -0,0 +1,4 @@+This package uses tagstream-conduit for its parser. It automatically balances+mismatched tags, so that there shouldn't be any parse failures. It does not+handle a full HTML document rendering, such as adding missing html and head+tags.
Text/HTML/DOM.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, CPP #-}+{-# LANGUAGE OverloadedStrings #-} module Text.HTML.DOM ( eventConduit , sinkDoc@@ -10,9 +10,7 @@ import Control.Monad.Trans.Resource import Prelude hiding (readFile) import qualified Data.ByteString as S-#if MIN_VERSION_tagstream_conduit(0,5,0) import qualified Text.HTML.TagStream.Text as TS-#endif import qualified Text.HTML.TagStream as TS import qualified Data.XML.Types as XT import Data.Conduit@@ -41,7 +39,7 @@ where go stack = do mx <- await- case fmap entities mx of+ case mx of Nothing -> closeStack stack -- Ignore processing instructions (or pseudo-instructions)@@ -74,24 +72,6 @@ Just TS.Incomplete{} -> go stack toName l = XT.Name l Nothing Nothing closeStack = mapM_ (yield . XT.EventEndElement)-- entities :: TS.Token' Text -> TS.Token' Text- entities (TS.TagOpen x pairs b) = TS.TagOpen x (map (second entities') pairs) b- entities (TS.Text x) = TS.Text $ entities' x- entities ts = ts-- entities' :: Text -> Text- entities' t =- case T.break (== '&') t of- (_, "") -> t- (before, t') ->- case T.break (== ';') $ T.drop 1 t' of- (_, "") -> t- (entity, rest') ->- let rest = T.drop 1 rest'- in case decodeHtmlEntities entity of- XT.ContentText entity' -> T.concat [before, entity', entities' rest]- XT.ContentEntity _ -> T.concat [before, "&", entity, entities' rest'] isVoid = flip Set.member $ Set.fromList [ "area"
html-conduit.cabal view
@@ -1,5 +1,5 @@ Name: html-conduit-Version: 1.1.1.1+Version: 1.1.1.2 Synopsis: Parse HTML documents using xml-conduit datatypes. Description: This package uses tagstream-conduit for its parser. It automatically balances mismatched tags, so that there shouldn't be any parse failures. It does not handle a full HTML document rendering, such as adding missing html and head tags. Homepage: https://github.com/snoyberg/xml@@ -9,7 +9,7 @@ Maintainer: michael@snoyman.com Category: Web, Text, Conduit Build-type: Simple-Extra-source-files: test/main.hs+Extra-source-files: test/main.hs README.md ChangeLog.md Cabal-version: >=1.8 Library@@ -24,7 +24,7 @@ , conduit-extra >= 1.1.1 , system-filepath >= 0.4 && < 0.5 , xml-conduit >= 1.1 && < 1.3- , tagstream-conduit >= 0.4 && < 0.6+ , tagstream-conduit >= 0.5.5.3 && < 0.6 , xml-types >= 0.3 && < 0.4 test-suite test
test/main.hs view
@@ -86,3 +86,11 @@ ] ] in H.parseLBS html @?= doc++ it "doesn't double unescape" $+ let html = "<p>Hello &gt; World</p>"+ doc = X.Document (X.Prologue [] Nothing []) root []+ root = X.Element "p" Map.empty+ [ X.NodeContent "Hello > World"+ ]+ in H.parseLBS html @?= doc