Skip to content

Commit

Permalink
fix multi-byte parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 committed Nov 10, 2016
1 parent c1ce997 commit 564adfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function parsexml(xmlstring::AbstractString)
(:xmlParseMemory, libxml2),
Ptr{_Node},
(Cstring, Cint),
xmlstring, length(xmlstring))
xmlstring, sizeof(xmlstring))
if ptr == C_NULL
throw_xml_error()
end
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ end
@test nodetype(parsexml("<xml/>".data).node) === EzXML.XML_DOCUMENT_NODE
@test nodetype(parsexml("<html/>".data).node) === EzXML.XML_DOCUMENT_NODE

# This includes multi-byte characters.
doc = parse(Document, """
<?xml version="1.0" encoding="UTF-8" ?>
<Link>
<Name>pubmed_pubmed</Name>
<Menu>Similar articles</Menu>
<Description>... “linked from” ...</Description>
<DbTo>pubmed</DbTo>
</Link>
""")
@test nodetype(doc.node) === EzXML.XML_DOCUMENT_NODE

@test_throws ArgumentError parse(Document, "")
@test_throws XMLError parse(Document, " ")
@test_throws XMLError parse(Document, "abracadabra")
Expand Down

0 comments on commit 564adfe

Please sign in to comment.