Skip to content

Commit

Permalink
GH#198: fix file path encoding and error handling in resolver code
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed Jul 18, 2016
1 parent e9bf966 commit 5da090b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lxml/parser.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,19 @@ cdef xmlparser.xmlParserInput* _local_resolver(const_char* c_url, const_char* c_
if doc_ref is not None:
if doc_ref._type == PARSER_DATA_STRING:
data = doc_ref._data_bytes
filename = doc_ref._filename
if not filename:
filename = None
elif not isinstance(filename, bytes):
# most likely a text URL
filename = filename.encode('utf8')
if not isinstance(filename, bytes):
filename = None

c_input = xmlparser.xmlNewInputStream(c_context)
if c_input is not NULL:
if doc_ref._filename:
c_input.filename = <char *>tree.xmlStrdup(_xcstr(doc_ref._filename))
if filename is not None:
c_input.filename = <char *>tree.xmlStrdup(_xcstr(filename))
c_input.base = _xcstr(data)
c_input.length = python.PyBytes_GET_SIZE(data)
c_input.cur = c_input.base
Expand Down

0 comments on commit 5da090b

Please sign in to comment.