정규식 'Watched word' 충돌 확인 (2025)

이 방식으로는 사람들이 “일반” 와일드카드 표현식을 입력한 이후감시 단어 정규식 활성화 옵션을 켜는 것을 막을 수 없습니다. 이번 사례가 바로 그런 경우였습니다.

정규식 호출 주위에 예외 처리기를 추가하는 것만으로도 충분할 것 같습니다.

  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개의 좋아요