chocoteam / chocoteam/choco-solver

Accidental special characters from integers in regex

Open
#337 1 comment 0 reactions 0 assignees View on GitHub
regular
Dominant language
Java
Stars
779
Forks
159
Avg merge
6d 9h
Merged PRs (30d)
10

Description

I'd expect any integer in the `<123>` format in a FiniteAutomaton regex to parse that integer. But certain integers conflict with already-defined [operators](http://www.brics.dk/automaton/doc/index.html) and therefore cause the FiniteAutomaton constructor to do something wrong:
- `FiniteAutomaton("<43>")` hangs (it gets converted to `"."`)
- `FiniteAutomaton("<59>")` hangs (it gets converted to `"@"`)
- `FiniteAutomaton("<117>")` throws an exception (it gets converted to `"~"`)

There are likely more integers that aren't hanging or throwing, but are getting converted to other operators (like `+`, `*`, `?`) and producing automata with the wrong behavior.

Have you considered putting a backslash in front of the character during the int parsing and conversion step in [`StringUtils.toCharExp()`](https://github.com/chocoteam/choco3/blob/master/choco-solver/src/main/java/org/chocosolver/util/tools/StringUtils.java#L84)? e.g. `"<43>"` would converted to `\.` and wouldn't trigger the behavior of an operator if it conflicts with one.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.