Skip to content

Replace invalid characters with U+FFFD (fixes #96) #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Patches and suggestions
- Juan Carlos Garcia Segovia
- Mike West
- Marc DM
- Leif Arne Storset
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Change Log
Released on XXX, 2014

* XXX
* Fix #96: replace invalid characters from "Preprocessing the input stream" with
U+FFFD, preventing problems in lxml.


0.999
Expand Down
1 change: 1 addition & 0 deletions html5lib/inputstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def readChunk(self, chunkSize=None):
# Replace invalid characters
# Note U+0000 is dealt with in the tokenizer
data = self.replaceCharactersRegexp.sub("\ufffd", data)
data = invalid_unicode_re.sub("\ufffd", data)

data = data.replace("\r\n", "\n")
data = data.replace("\r", "\n")
Expand Down