RGJ
(Richard - Communiteq)
Setembro 12, 2025, 9:11am
1
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 curtidas
pfaffman
(Jay Pfaffman)
Setembro 12, 2025, 11:18am
2
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 curtida
RGJ
(Richard - Communiteq)
Setembro 12, 2025, 11:03pm
3
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 curtida
pfaffman
(Jay Pfaffman)
Setembro 12, 2025, 11:16pm
4
Well, now it’s obvious when you say it like that.
sam
(Sam Saffron)
Setembro 15, 2025, 12:19am
5
Valildating regex in on save seems like a very sane thing to do.
putting a pr-welcome on this, but team will triage and decide if it makes sense to do this in the upcoming weeks to save us future support.
1 curtida
RGJ
(Richard - Communiteq)
Setembro 15, 2025, 8:17am
6
That won’t prevent people entering “normal” wildcard expressions, and then turning on watched words regular expressions enabled
, which is what happened here.
I think it just needs an exception handler around the regexp call
def word_matches?(word, case_sensitive: false)
options = case_sensitive ? nil : Regexp::IGNORECASE
Regexp.new(WordWatcher.word_to_regexp(word), options).match?(@raw)
end
2 curtidas
zogstrip
(Régis Hanol)
Outubro 6, 2025, 5:25pm
7
Thanks for the report @RGJ , this will be fixed by
main
← fix-watched-words-regexp
opened 05:25PM - 06 Oct 25 UTC
If you have a watched word with a wildcard and then enable the "watched words re… gexp" site setting, you might end up in a situation where you can't post anymore because of the invalid regexp.
This ensures we correctly skip invalid regexps.
Ref - https://meta.discourse.org/t/-/382417
3 curtidas
zogstrip
(Régis Hanol)
Fechado
Outubro 7, 2025, 6:00am
9
This topic was automatically closed after 10 hours. New replies are no longer allowed.