# 「Watch Words」の無効な正規表現により、どのWatch Wordも機能しません

**URL:** <https://meta.discourse.org/t/invalid-regular-expressions-in-watched-words-makes-no-watched-word-work/192160>\
**Category:** Bug\
**Tags:** watched-words\
**Created:** [2021 年 5 月 31 日午前 10:15 UTC](https://meta.discourse.org/t/invalid-regular-expressions-in-watched-words-makes-no-watched-word-work/192160 "2021-05-31T10:15:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![blattersturm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blattersturm/32/76134_2.png) [@blattersturm](https://meta.discourse.org/u/blattersturm)\
**Post date:** [2021 年 5 月 31 日午前 10:15 UTC](https://meta.discourse.org/t/invalid-regular-expressions-in-watched-words-makes-no-watched-word-work/192160/1 "2021-05-31T10:15:33Z")

</div>

`監視ワードの正規表現` 設定を有効にすると、無効な正規表現が特定の監視ワードカテゴリ全体を機能不全に陥らせます。

# 再現手順

1. 「監視ワードの正規表現」を有効にします。
2. 「承認が必要」に監視ワードパターンを追加します（例：`same issue`）。
3. 無効な監視ワードパターンを追加します（例：`*ban*`。これは正規表現を有効にする前にワイルドカードを含む監視ワードを持っていた場合に該当します）。
4. 「same issue」を含む投稿が承認キューをスキップし、「テスト」フォームでも無視されることに注意してください。
5. 無効な監視ワードを削除します。
6. 「same issue」が正しく一致するようになったことを確認してください。

# 再現手順（より深刻なケース）:

1. 「監視ワードの正規表現」と「タグ」を有効にします。
2. 「タグ」に無効な監視ワードパターンを追加します（例：`*tebex.io*` → `paid`）。
3. 新しいトピックを投稿しようとします。これにより「Error 500」が返され、`/logs` に以下の結果が表示されます:

```plaintext
RegexpError (target of repeat operator is not specified: /*tebex.io*/)
app/services/word_watcher.rb:116:in `initialize'
app/services/word_watcher.rb:116:in `new'
app/services/word_watcher.rb:116:in `matches?'
lib/topic_creator.rb:184:in `block in setup_tags'
lib/topic_creator.rb:183:in `each'
lib/topic_creator.rb:183:in `setup_tags'
lib/topic_creator.rb:46:in `create'
lib/post_creator.rb:501:in `create_topic'

```

# 補足

正規表現が無効な場合でも、例えば `/` ブロックで囲まれていれば、ワイルドカードと同様に有効な正規表現の入力を許可するとよいと思います。特に、既存の監視ワードにワイルドカードが含まれている場合、この切り替えが深刻な問題を引き起こす可能性があるためです。

---

_[View the full topic](https://meta.discourse.org/t/invalid-regular-expressions-in-watched-words-makes-no-watched-word-work/192160)._
