asn1rt: fix to_asn1() corner case conversion of printable string

This commit is contained in:
p1-bmu 2021-05-31 12:33:49 +02:00
parent 5f9beb525d
commit 3e0b832d4a
2 changed files with 5 additions and 5 deletions

View File

@ -286,7 +286,7 @@ Specific constraints attributes:
else:
s = uint_to_bytes(self._val[0], self._val[1]).decode('ascii')
if is_printable(s):
return ret + ' -- %s --' % s
return ret + ' -- %r --' % s
else:
return ret
except Exception:
@ -1325,7 +1325,7 @@ Specific constraints attributes:
try:
s = self._val.decode('ascii')
if is_printable(s):
return ret + ' -- %s --' % s
return ret + ' -- %r --' % s
else:
return ret
except Exception:

View File

@ -361,11 +361,11 @@ def extract_charstr(text=''):
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
printable_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
_printable_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
def is_printable(w):
return all(c in printable_str for c in w)
return all(c in _printable_str for c in w)
#------------------------------------------------------------------------------#
# integer factorization and rounding routine