niklasb / webkit-server

[not actively maintained] The C++ webkit-server from capybara-webkit with useful extensions and Python bindings
MIT License
48 stars 38 forks source link

problem with issue_command and unicode characters #30

Open pjrobertson opened 7 years ago

pjrobertson commented 7 years ago

There's a bug in issue_command() because the len() argument sent to the driver may be different from the actual length of the string.

This is relevant to this line in the code

Take an example where *args is a single argument of value 北京 (that is two Chinese characters for the city 'Beijing'. At present, self._writeline(str(len(arg))) will write '2' for the length of this argument. But the following line encodes the character using utf-8 giving a value of b'\xe8\xa5\xbf\xe5\xae\x89'. This is length '6'. This causes all subsequent commands sent to the driver to fail.

Making sure the arg is coded before getting its length fixes this problem