asn1rt: fix to_asn1() corner case conversion of printable string
This commit is contained in:
parent
5f9beb525d
commit
3e0b832d4a
|
@ -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:
|
||||
|
|
|
@ -361,11 +361,11 @@ def extract_charstr(text=''):
|
|||
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
|
||||
|
||||
|
||||
printable_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\
|
||||
_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
|
||||
|
|
Loading…
Reference in New Issue