Skip to content

Commit b01a045

Browse files
committed
removing null byte characters from the body
1 parent 33f084f commit b01a045

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

parsel/selector.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _st(st):
3838
def create_root_node(text, parser_cls, base_url=None):
3939
"""Create root node for text using given parser class.
4040
"""
41-
body = text.strip().encode('utf8') or b'<html/>'
41+
body = text.strip().replace('\x00', '').encode('utf8') or b'<html/>'
4242
parser = parser_cls(recover=True, encoding='utf8')
4343
root = etree.fromstring(body, parser=parser, base_url=base_url)
4444
if root is None:
@@ -188,7 +188,6 @@ def __init__(self, text=None, type=None, namespaces=None, root=None,
188188
self._tostring_method = _ctgroup[st]['_tostring_method']
189189

190190
if text is not None:
191-
text = text.replace('\x00', '')
192191
if not isinstance(text, six.text_type):
193192
raise TypeError("text argument should be of type %s" % six.text_type)
194193
root = self._get_root(text, base_url)

0 commit comments

Comments
 (0)