Skip to content

Commit

Permalink
Fix bug with pastes containing Unicode symbols failing to be uploaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matoking committed Apr 23, 2015
1 parent 6e4bd88 commit e0c0d17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pastes/models.py
Expand Up @@ -137,7 +137,7 @@ def add_paste(text, user=None, title="Untitled", expiration=None, visibility=Non

# Generate a random 8 character string for the char ID
char_id = Paste.get_random_char_id()
hash = hashlib.sha256(text).hexdigest()
hash = hashlib.sha256(text.encode('utf-8')).hexdigest()
submitted = datetime.datetime.now()

# Make paste hidden if its visibility is hidden (private visibility may be added later)
Expand Down Expand Up @@ -185,7 +185,7 @@ def update_paste(id=None, char_id=None, text="", title="", visibility=None, form
else:
hidden = False

hash = hashlib.sha256(text).hexdigest()
hash = hashlib.sha256(text.encode('utf-8')).hexdigest()

with transaction.atomic():
# Save the new paste content both as raw text and with formatting
Expand Down Expand Up @@ -339,7 +339,7 @@ def add_paste_text(text, format=None):
If format other than None is provided, Pygments will be used to highlight the text
"""
hash = hashlib.sha256(text).hexdigest()
hash = hashlib.sha256(text.encode('utf-8')).hexdigest()

if format != None:
text = highlighting.format_text(text, format)
Expand Down

0 comments on commit e0c0d17

Please sign in to comment.