summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorocramz <>2017-11-23 08:55:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-11-23 08:55:00 (GMT)
commitfbffb1179d48a348116c092c8b192115ab04d2c6 (patch)
tree24574ec931ccfe01e518647b55e928ce01151ca6
parentef0d4791d2e968186fe9fff67c017b14cfd23da4 (diff)
version 0.3.20.3.2
-rw-r--r--CHANGELOG.markdown19
-rw-r--r--src/Xeno/DOM.hs11
-rw-r--r--test/Main.hs6
-rw-r--r--xeno.cabal2
4 files changed, 24 insertions, 14 deletions
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index 3cbbadc..7d00300 100644
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -1,10 +1,13 @@
-0.3
-Fixed name parsing (for attributes and tags) so it conforms with the XML spec (qrilka)
-Fixed parsing failure when root tag is preceded by white space (though without checking for white space characters specifically) (qrilka)
-Added contribution guidelines (ocramz)
+ 0.3.2
+ Fixed DOM parsing from bystrings with non-zero offset (qrilka)
+
+ 0.3
+ Fixed name parsing (for attributes and tags) so it conforms with the XML spec (qrilka)
+ Fixed parsing failure when root tag is preceded by white space (though without checking for white space characters specifically) (qrilka)
+ Added contribution guidelines (ocramz)
-0.2
-Added CDATA support (Rembane)
+ 0.2
+ Added CDATA support (Rembane)
-0.1
-First Hackage release
+ 0.1
+ First Hackage release
diff --git a/src/Xeno/DOM.hs b/src/Xeno/DOM.hs
index cfa43d1..78feadb 100644
--- a/src/Xeno/DOM.hs
+++ b/src/Xeno/DOM.hs
@@ -138,6 +138,7 @@ parse str =
-- characters
Just 0x1 -> go (n+3)
_ -> Nothing
+ PS _ offset0 _ = str
node =
runST
(do nil <- UMV.new 1000
@@ -162,7 +163,7 @@ parse str =
writeRef sizeRef (index + 5)
do UMV.write v' index tag
UMV.write v' (index + 1) tag_parent
- UMV.write v' (index + 2) name_start
+ UMV.write v' (index + 2) (name_start - offset0)
UMV.write v' (index + 3) name_len
UMV.write v' (index + 4) tag_end)
(\(PS _ key_start key_len) (PS _ value_start value_len) -> do
@@ -178,9 +179,9 @@ parse str =
let tag = 0x02
do writeRef sizeRef (index + 5)
do UMV.write v' index tag
- UMV.write v' (index + 1) key_start
+ UMV.write v' (index + 1) (key_start - offset0)
UMV.write v' (index + 2) key_len
- UMV.write v' (index + 3) value_start
+ UMV.write v' (index + 3) (value_start - offset0)
UMV.write v' (index + 4) value_len)
(\_ -> return ())
(\(PS _ text_start text_len) -> do
@@ -196,7 +197,7 @@ parse str =
return v'
do writeRef sizeRef (index + 3)
do UMV.write v' index tag
- UMV.write v' (index + 1) text_start
+ UMV.write v' (index + 1) (text_start - offset0)
UMV.write v' (index + 2) text_len)
(\_ -> do
v <- readSTRef vecRef
@@ -220,7 +221,7 @@ parse str =
return v'
do writeRef sizeRef (index + 3)
do UMV.write v' index tag
- UMV.write v' (index + 1) cdata_start
+ UMV.write v' (index + 1) (cdata_start - offset0)
UMV.write v' (index + 2) cdata_len)
str
wet <- readSTRef vecRef
diff --git a/test/Main.hs b/test/Main.hs
index 8f06156..d12ebc5 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -5,6 +5,7 @@
module Main where
import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
import Test.Hspec
import Xeno.SAX
import Xeno.DOM
@@ -42,6 +43,11 @@ spec =
parsedRoot = fromRightE $ Xeno.DOM.parse docWithPrologue
name parsedRoot `shouldBe` "greeting"
+ it "DOM from bytestring substring" $ do
+ let substr = BS.drop 5 "5<8& <valid>xml<here/></valid>"
+ parsedRoot = fromRightE $ Xeno.DOM.parse substr
+ name parsedRoot `shouldBe` "valid"
+
-- If this works without crashing we're happy.
let nsdoc = "<ns:tag os:attr=\"Namespaced attribute value\">Content.</ns:tag>"
it
diff --git a/xeno.cabal b/xeno.cabal
index 8b94497..77d9964 100644
--- a/xeno.cabal
+++ b/xeno.cabal
@@ -1,5 +1,5 @@
name: xeno
-version: 0.3.1
+version: 0.3.2
synopsis: A fast event-based XML parser in pure Haskell
description: Please see README.md
build-type: Simple