ossobv / asterisklint

Asterisk PBX configuration syntax checker
GNU General Public License v3.0
63 stars 12 forks source link

Inclusion of commas inside of brackets raise an exception #45

Open altmas5 opened 4 years ago

altmas5 commented 4 years ago

I'm not saying that the Pattern Matching syntax is correct here, but it raised an exception exten => _XXX[1,2,3,7,8]XXX,1,NoOp(DEBUG)

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/asterisklint/config.py", line 186, in __iter__
    self.on_varset(element)
  File "/usr/local/lib/python3.8/site-packages/asterisklint/dialplan.py", line 600, in on_varset
    dialplanvarset = DialplanVarset.from_varset(varset)
  File "/usr/local/lib/python3.8/site-packages/asterisklint/dialplan.py", line 507, in from_varset
    pattern = pattern and Pattern(pattern, varset.where) or None
  File "/usr/local/lib/python3.8/site-packages/asterisklint/pattern.py", line 107, in __init__
    self.values = self.parse(pattern)
  File "/usr/local/lib/python3.8/site-packages/asterisklint/pattern.py", line 116, in parse
    return tuple([Pattern.IS_A_PATTERN] + cls.parse_pattern(raw[1:]))
  File "/usr/local/lib/python3.8/site-packages/asterisklint/pattern.py", line 143, in parse_pattern
    range_end = raw.index(0x5d)  # ']'
ValueError: 93 is not in list

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/asterisklint", line 34, in <module>
    sys.exit(main(sys.argv[1:], os.environ))
  File "/usr/local/lib/python3.8/site-packages/asterisklint/main.py", line 178, in main
    return command_module.main(args, envs)
  File "/usr/local/lib/python3.8/site-packages/asterisklint/mainutil.py", line 35, in __call__
    return self.handle_args(args)
  File "/usr/local/lib/python3.8/site-packages/asterisklint/commands/dialplan-check.py", line 50, in handle_args
    dialplan = next(iter(parser))
  File "/usr/local/lib/python3.8/site-packages/asterisklint/config.py", line 192, in __iter__
    raise ProgrammingError(str(element.where)) from exc
asterisklint.config.ProgrammingError: An unexpected exception was raised. This is most likely a bug in the asterisklint library. If you can reproduce the problem and file an issue on the bug tracker, that would be nice. Further info: extensions.conf:4079

I already fixed the expression to: exten => _XXX[1-378]XXX,1,NoOp(DEBUG)

The exception is not raised anymore, so the commas inside of brackets make it break.