asn1c: enable improper extension notation for size and alphabet constraint

This commit is contained in:
p1-bmu 2021-11-09 15:48:17 +01:00
parent c70b331b53
commit 5372dcda0d
4 changed files with 36 additions and 20 deletions

View File

@ -4159,11 +4159,23 @@ class ASN1Obj(object):
# 4) transfer references from ObjProxy to self
if ObjProxy._ref:
self._ref.update( ObjProxy._ref )
#
# 5) check for some more funny constraint
m = SYNT_RE_CONST_EXT.match(rest)
if m:
# previous constraint must be considered extensible
const = self.select(['const', const_index])
if const['ext'] is None:
const['ext'] = []
rest = rest[m.end():].lstrip()
elif rest[0:1] == '^':
# intersection with a 2nd constraint
self._parse_const('(%s)' % rest[1:].lstrip())
# this is a hack, and this is bad
rest = ''
if rest:
# may have ", ..." or "^ $other_constraint"
asnlog('WNG: remaining text for SIZE constraint, {1}'\
.format(self.fullname(), rest))
raise(ASN1ProcTextErr('{0}: remaining text for SIZE constraint, {1}'\
.format(self.fullname(), rest)))
def _parse_const_alphabet(self, const):
const_index = len(self._const)
@ -4216,11 +4228,23 @@ class ASN1Obj(object):
# 4) transfer references from ObjProxy to self
if ObjProxy._ref:
self._ref.update( ObjProxy._ref )
#
# 5) check for some more funny constraint
m = SYNT_RE_CONST_EXT.match(rest)
if m:
# previous constraint must be considered extensible
const = self.select(['const', const_index])
if const['ext'] is None:
const['ext'] = []
rest = rest[m.end():].lstrip()
elif rest[0:1] == '^':
# intersection with a 2nd constraint
self._parse_const('(%s)' % rest[1:].lstrip())
# this is a hack, and this is bad
rest = ''
if rest:
# may have ", ..." or "^ $other_constraint"
asnlog('WNG: remaining text for ALPHABET constraint, {1}'\
.format(self.fullname(), rest))
raise(ASN1ProcTextErr('{0}: remaining text for SIZE constraint, {1}'\
.format(self.fullname(), rest)))
def _parse_const_withcomp(self, const):
const_index = len(self._const)

View File

@ -334,18 +334,6 @@ SYNT_RE_MODULEDEF = re.compile(
SYNT_RE_MODULEREF = re.compile(
'(?:^|\s{1})(%s){1}\s{0,}(\{[\s\-a-zA-Z0-9\(\)]{1,}\}){0,1}' % _RE_TYPEREF)
'''
# FROM $ModuleRef $ModuleOIDOrOIDRef{0,1}
SYNT_RE_MODULEFROM = re.compile(
'(?:FROM\s{1,})(%s)' \
'(?:\s*' \
'(\{[\s\-a-zA-Z0-9\(\)]{1,}\})|' \
'\s{1,}(%s)(?:\s{1,}%s(?:\s*\{\})?(?:\s*,|\s{1,}FROM)|\s*$)' \
'){0,1}' \
'(?:\s*WITH\s{1,}(SUCCESSORS|DESCENDANTS)){0,1}' \
% (_RE_TYPEREF, _RE_IDENT, _RE_WORD))
# TODO, catch "WITH SUCCESSORS" / "WITH DESCENDANTS" after the imported module name
'''
SYNT_RE_MODULEFROM = re.compile(
'(?:FROM\s{1,})(%s)\s*' % _RE_TYPEREF)
SYNT_RE_MODULEFROM_SYM = re.compile(
@ -420,6 +408,8 @@ SYNT_RE_TIMEGENE = re.compile(
SYNT_RE_CONST_DISPATCH = re.compile(
'(?:^|\s{1})(INCLUDES)|(SIZE)|(FROM)|(WITH COMPONENTS)|(WITH COMPONENT)|' \
'(PATTERN)|(SETTINGS)|(CONTAINING)|(ENCODED BY)|(CONSTRAINED BY)')
SYNT_RE_CONST_EXT = re.compile(
',\s{0,}\.\.\.')
SYNT_RE_GROUPVERS = re.compile(
'(?:^|\s{1})[0-9]{1,}\s{0,1}\:')

View File

@ -7488,6 +7488,7 @@ class MULTIMEDIA_SYSTEM_CONTROL:
_UserInputIndication_signal = SEQ(name=u'signal', mode=MODE_TYPE, tag=(3, TAG_CONTEXT_SPEC, TAG_IMPLICIT))
__UserInputIndication_signal_signalType = STR_IA5(name=u'signalType', mode=MODE_TYPE, tag=(0, TAG_CONTEXT_SPEC, TAG_IMPLICIT))
__UserInputIndication_signal_signalType._const_sz = ASN1Set(rv=[1], rr=[], ev=None, er=[])
__UserInputIndication_signal_signalType._const_alpha = ASN1Set(rv=[u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'#', u'*', u'A', u'B', u'C', u'D', u'!'], rr=[], ev=None, er=[])
__UserInputIndication_signal_duration = INT(name=u'duration', mode=MODE_TYPE, tag=(1, TAG_CONTEXT_SPEC, TAG_IMPLICIT), opt=True)
__UserInputIndication_signal_duration._const_val = ASN1Set(rv=[], rr=[ASN1RangeInt(lb=1, ub=65535)], ev=None, er=[])
__UserInputIndication_signal_rtp = SEQ(name=u'rtp', mode=MODE_TYPE, tag=(2, TAG_CONTEXT_SPEC, TAG_IMPLICIT), opt=True)

View File

@ -6669,6 +6669,7 @@ class MULTIMEDIA_SYSTEM_CONTROL:
_UserInputIndication_signal = SEQ(name=u'signal', mode=MODE_TYPE, tag=(3, TAG_CONTEXT_SPEC, TAG_IMPLICIT))
__UserInputIndication_signal_signalType = STR_IA5(name=u'signalType', mode=MODE_TYPE, tag=(0, TAG_CONTEXT_SPEC, TAG_IMPLICIT))
__UserInputIndication_signal_signalType._const_sz = ASN1Set(rv=[1], rr=[], ev=None, er=[])
__UserInputIndication_signal_signalType._const_alpha = ASN1Set(rv=[u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'#', u'*', u'A', u'B', u'C', u'D', u'!'], rr=[], ev=None, er=[])
__UserInputIndication_signal_duration = INT(name=u'duration', mode=MODE_TYPE, tag=(1, TAG_CONTEXT_SPEC, TAG_IMPLICIT), opt=True)
__UserInputIndication_signal_duration._const_val = ASN1Set(rv=[], rr=[ASN1RangeInt(lb=1, ub=65535)], ev=None, er=[])
__UserInputIndication_signal_rtp = SEQ(name=u'rtp', mode=MODE_TYPE, tag=(2, TAG_CONTEXT_SPEC, TAG_IMPLICIT), opt=True)