-
Notifications
You must be signed in to change notification settings - Fork 38
Fix encoding in forms #28
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,9 +513,12 @@ def issue_command(self, cmd, *args): | |
| self._writeline(cmd) | ||
| self._writeline(str(len(args))) | ||
| for arg in args: | ||
| arg = str(arg) | ||
| if type(arg) != str and type(arg) != unicode: | ||
| arg = str(arg) | ||
| if type(arg) == unicode: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only unicode strings need to be encoded as utf-8 to be sent as bytes to webkit server |
||
| arg = arg.encode("utf-8") | ||
| self._writeline(str(len(arg))) | ||
| self._sock.sendall(arg.encode("utf-8")) | ||
| self._sock.sendall(arg) | ||
|
|
||
| return self._read_response() | ||
|
|
||
|
|
@@ -537,5 +540,7 @@ def _read_message(self): | |
| return self.buf.read(size).decode("utf-8") | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a problem if you encode twice. Try the following:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Encoding twice can create errors:
|
||
| def _writeline(self, line): | ||
| if type(line) == unicode: | ||
| line = line.encode("utf-8") | ||
| """ Writes a line to the underlying socket. """ | ||
| self._sock.sendall(line.encode("utf-8") + b"\n") | ||
| self._sock.sendall(line + b"\n") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function cannot handle unicode strings. Try the following:
str(u"canción")