CapPaste: check the contents in can_post

For pastealacon, it is used to check for encoding compatibility.
This commit is contained in:
Laurent Bachelier 2011-05-04 23:50:58 +02:00
commit 0d2148bd84
6 changed files with 32 additions and 22 deletions

View file

@ -49,7 +49,11 @@ class PastealaconBackend(BaseBackend, BasePasteBackend):
def new_paste(self, *args, **kwargs):
return PastealaconPaste(*args, **kwargs)
def can_post(self, public=None, max_age=None):
def can_post(self, contents, public=None, max_age=None):
try:
contents.encode(self.browser.ENCODING)
except UnicodeEncodeError:
return 0
if public is False:
return 0
if max_age is not None: