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:
|
else:
|
||||||
s = uint_to_bytes(self._val[0], self._val[1]).decode('ascii')
|
s = uint_to_bytes(self._val[0], self._val[1]).decode('ascii')
|
||||||
if is_printable(s):
|
if is_printable(s):
|
||||||
return ret + ' -- %s --' % s
|
return ret + ' -- %r --' % s
|
||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -1325,7 +1325,7 @@ Specific constraints attributes:
|
||||||
try:
|
try:
|
||||||
s = self._val.decode('ascii')
|
s = self._val.decode('ascii')
|
||||||
if is_printable(s):
|
if is_printable(s):
|
||||||
return ret + ' -- %s --' % s
|
return ret + ' -- %r --' % s
|
||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -361,11 +361,11 @@ def extract_charstr(text=''):
|
||||||
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
|
re.subn('\s{0,}\n\s{0,}', '', text[1:cur])[0]
|
||||||
|
|
||||||
|
|
||||||
printable_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\
|
_printable_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\
|
||||||
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
|
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
|
||||||
|
|
||||||
def is_printable(w):
|
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
|
# integer factorization and rounding routine
|
||||||
|
|
Loading…
Reference in New Issue