Expresión regular de palabra observada falla (2025)

Similar to this one

Repro

  • watched words regular expressions enabled
  • watched words tag action
  • regular expression *abc

Result

It is impossible to create topics or posts

RegexpError (target of repeat operator is not specified: /(*abc)/i)
app/services/word_watcher.rb:239:in `initialize'
app/services/word_watcher.rb:239:in `new'
app/services/word_watcher.rb:239:in `word_matches?'
lib/topic_creator.rb:214:in `block in setup_tags'
lib/topic_creator.rb:213:in `each'
lib/topic_creator.rb:213:in `setup_tags'
lib/topic_creator.rb:48:in `create'
lib/post_creator.rb:493:in `create_topic'

Cause

  • * means “repeat the previous token zero or more times”
  • there is no previous token
2 Me gusta

So really the regex should be validated before allowing it to be added? And there should be a rescue so an invalid regex can’t crash the whole world?

1 me gusta

What obviously happened here is that the watched words were regular watched words and * was the wildcard, and then watched words regular expressions enabled was enabled.

So this

1 me gusta

Well, now it’s obvious when you say it like that. :rofl: