browser2: Add an option to convert POST data to the proper encoding

And autodetect it on forms. There is no other way to know what is the
expected encoding.
This commit is contained in:
Laurent Bachelier 2014-05-19 01:01:25 +02:00
commit 14b1b56914
3 changed files with 15 additions and 8 deletions

View file

@ -63,13 +63,10 @@ class CaptchaPage(HTMLPage):
class PostPage(HTMLPage):
# TODO handle encoding in Browser2
def post(self, paste, expiration=None):
encoding = 'ISO-8859-1'
form = self.get_form(name='editor')
form['code2'] = paste.contents.encode(encoding)
form['poster'] = paste.title.encode(encoding)
form['code2'] = paste.contents
form['poster'] = paste.title
if expiration:
form['expiry'] = expiration
form.submit()