aichaos / rivescript-go

A RiveScript interpreter for Go. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
60 stars 16 forks source link

Wrong regexp when escaping wildcards in optionals #15

Closed kirsle closed 7 years ago

kirsle commented 7 years ago

Via @marceloverdijk on Slack:

https://github.com/aichaos/rivescript-go/blob/7f29a68d4cf2aa8ef7501717d24f3bb549f30fc0/src/tags.go#L81

This regexp is incorrect and should be patched as follows:

- pipes = strings.Replace(pipes, `(\d+?)`, `(?:\w+?)`, -1)
+ pipes = strings.Replace(pipes, `(\w+?)`, `(?:\w+?)`, -1)

And add a unit test that checks for wildcards in optionals like [_] and [#] for good measure.