Skip to content

Commit 638797c

Browse files
committed
Updated the decrypt() templatetag to ensure it returns string rather than bytes.
- Legacy-Id: 18481
1 parent 90a6ed0 commit 638797c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ietf/nomcom/templatetags/nomcom_tags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django import template
77
from django.conf import settings
88
from django.template.defaultfilters import linebreaksbr, force_escape
9+
from django.utils.encoding import force_text
910
from django.utils.safestring import mark_safe
1011

1112
import debug # pyflakes:ignore
@@ -66,6 +67,10 @@ def decrypt(string, request, year, plain=False):
6667
command = "%s smime -decrypt -in %s -inkey /dev/stdin"
6768
code, out, error = pipe(command % (settings.OPENSSL_COMMAND,
6869
encrypted_file.name), key)
70+
try:
71+
out = force_text(out)
72+
except Exception:
73+
pass
6974
if code != 0:
7075
log("openssl error: %s:\n Error %s: %s" %(command, code, error))
7176

0 commit comments

Comments
 (0)