hexpat 0.19.8 → 0.19.9
raw patch · 3 files changed
+33/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Text/XML/Expat/Format.hs +17/−3
- hexpat.cabal +8/−5
- test/suite/Text/XML/Expat/ParseFormat.hs +8/−0
Text/XML/Expat/Format.hs view
@@ -55,6 +55,8 @@ import Data.List.Class import Data.Monoid import Data.Word+import Data.Text (Text)+import Text.XML.Expat.Tree (UNode) -- | DEPRECATED: Renamed to 'format'. formatTree :: (NodeClass n [], GenericXMLString tag, GenericXMLString text) =>@@ -67,6 +69,7 @@ n [] tag text -> L.ByteString format node = L.fromChunks (xmlHeader : formatNodeG node)+{-# SPECIALIZE format :: UNode Text -> L.ByteString #-} -- | Format document with <?xml.. header - generalized variant that returns a generic -- list of strict ByteStrings.@@ -105,6 +108,7 @@ n c tag text -> c B.ByteString formatNodeG = formatSAXG . treeToSAX+{-# SPECIALIZE formatNodeG :: UNode Text -> [B.ByteString] #-} -- | Format an XML document - lazy variant that returns lazy ByteString. formatDocument :: (Doc.DocumentClass d [], GenericXMLString tag, GenericXMLString text) =>@@ -173,6 +177,7 @@ where singleton = return concatL = join+{-# SPECIALIZE treeToSAX :: UNode Text -> [(SAXEvent Text Text)] #-} -- | Format SAX events with no header - lazy variant that returns lazy ByteString. formatSAX :: (GenericXMLString tag, GenericXMLString text) =>@@ -210,6 +215,7 @@ c (SAXEvent tag text) -- ^ SAX events -> c B.ByteString formatSAXG l1 = formatSAXGb l1 False+{-# SPECIALIZE formatSAXG :: [SAXEvent Text Text] -> [B.ByteString] #-} formatSAXGb :: forall c tag text . (List c, GenericXMLString tag, GenericXMLString text) =>@@ -287,21 +293,29 @@ formatSAXGb l2 cd Cons (FailDocument _) l2 -> formatSAXGb l2 cd+{-# SPECIALIZE formatSAXGb :: [SAXEvent Text Text] -> Bool -> [B.ByteString] #-} pack :: String -> B.ByteString pack = B.pack . map c2w -escapees :: [Word8]-escapees = map c2w "&<\"'"+isSafeChar :: Word8 -> Bool+isSafeChar c =+ (c /= c2w '&')+ && (c /= c2w '<')+ && (c /= c2w '>')+ && (c /= c2w '"')+ && (c /= c2w '\'')+{-# INLINE isSafeChar #-} escapeText :: B.ByteString -> [B.ByteString] escapeText str | B.null str = [] escapeText str =- let (good, bad) = B.span (`notElem` escapees) str+ let (good, bad) = B.span isSafeChar str in if B.null good then case w2c $ B.head str of '&' -> pack "&":escapeText rema '<' -> pack "<":escapeText rema+ '>' -> pack ">":escapeText rema '"' -> pack """:escapeText rema '\'' -> pack "'":escapeText rema _ -> error "hexpat: impossible"
hexpat.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6 Name: hexpat-Version: 0.19.8+Version: 0.19.9 Synopsis: XML parser/formatter based on expat Description: This package provides a general purpose Haskell XML library using Expat to@@ -51,7 +51,8 @@ on Linux, Mac and Windows (thanks Jacob Stanley); 0.19.3 fix misconfiguration of expat which broke entity parsing; 0.19.4 bump version constraint for text; 0.19.5 bump text to < 0.12 and fix text-0.10.0.1 breakage; 0.19.6 dependency breakage with List;- 0.19.7 ghc-7.2.1 compatibility; 0.19.8 fix space leak on lazy parse under ghc-7.2.1+ 0.19.7 ghc-7.2.1 compatibility; 0.19.8 fix space leak on lazy parse under ghc-7.2.1;+ 0.19.9 fix formatting of > character + improve performance Category: XML License: BSD3 License-File: LICENSE@@ -62,16 +63,18 @@ Evan Martin (who started the project), Matthew Pocock [drdozer], Kevin Jardine,- Jacob Stanley+ Jacob Stanley,+ Simon Hengel Maintainer: http://blacksapphire.com/antispam/ Copyright: (c) 2009 Doug Beardsley <mightybyte@gmail.com>,- (c) 2009-2010 Stephen Blackheath <http://blacksapphire.com/antispam/>,+ (c) 2009-2012 Stephen Blackheath <http://blacksapphire.com/antispam/>, (c) 2009 Gregory Collins, (c) 2008 Evan Martin <martine@danga.com>, (c) 2009 Matthew Pocock <matthew.pocock@ncl.ac.uk>, (c) 2007-2009 Galois Inc.,- (c) 2010 Kevin Jardine+ (c) 2010 Kevin Jardine,+ (c) 2012 Simon Hengel Homepage: http://haskell.org/haskellwiki/Hexpat/ Extra-Source-Files: test/hexpat-tests.cabal,
test/suite/Text/XML/Expat/ParseFormat.hs view
@@ -141,6 +141,14 @@ [Text "Ro", Text "se & Crown"] ()] ()), -- Test text normalization pfOutXML = [], pfImpls = [Tree, Annotated, Extended]+ },+ PFTest {+ pfName = "escaping of >",+ pfXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<text>]]></text>",+ pfDoc = Document (Just (XMLDeclaration "1.0" (Just "UTF-8") Nothing)) Nothing [] (+ Element "text" [] [Text "]]>"] ()),+ pfOutXML = [],+ pfImpls = [Extended] } ]