테스트 감시 단어 기능이 작동하지 않습니다

감시 단어 설정 화면에서 “test” 기능을 사용할 때, “raw bracket is not allowed in regular expression with unicode flag” 오류가 콘솔에 반복적으로 출력됩니다.

  1. https://meta.discourse.org/admin/customize/watched_words/action/require_approval 로 이동합니다.
  2. 브라우저 콘솔을 엽니다.
  3. “Test” 버튼을 누릅니다.
  4. 아무 내용이나 입력합니다.
  5. 오류를 확인합니다.

해당 오류는 watched-words.js에서 발생하며, 이는 전달되는 정규식 (?:[^[:word:]]|^)(word1|word2)(?=[^[:word:]]|$)이 Ruby에서는 유효하지만 JavaScript에서는 유효하지 않기 때문입니다. 이 정규식은 API인 https://meta.discourse.org/admin/customize/watched_words.json 에서 가져오며, 해당 API는 watched words serializer에서 JSON을 제공합니다. 이 시리얼라이저는 action만 전달하여 word watcher를 호출합니다.

몇 주 전이라면 문제가 없었을 것이지만, 특정 PR을 통해 두 개의 추가 매개변수가 도입되었습니다. 이 매개변수 중 하나는 engine이며, 기본값이 Ruby인 매개변수입니다. 앞서 언급한 호출에서는 이 매개변수가 지정되지 않았습니다. 따라서 반환되는 정규식은 Ruby 전용이지만, JavaScript 정규식 엔진에 의해 사용되고 있습니다.

5개의 좋아요

테스트 사이트에서 이 문제를 재현할 수 있습니다.

  • 차단된 감시 단어(Watched Word) 설정
  • 테스트 기능을 사용해 확인
  • 콘솔에서 이 오류 발생:
Uncaught SyntaxError: raw bracket is not allowed in regular expression with unicode flag
    createWatchedWordRegExp watched-words.js:12
    matches admin-watched-word-test.js:62
    matches admin-watched-word-test.js:61
    o handle-descriptor.js:61
    get Ember
    untrack validator.js:681
    Ember 3
    o reference.js:175
    tag reference.js:136
    track validator.js:668
    f reference.js:135
    <anonymous> runtime.js:2077
    tag reference.js:136
    track validator.js:668
    f reference.js:135
    evaluate runtime.js:2089
    _execute runtime.js:4306
    execute runtime.js:4291
    rerender runtime.js:4606
    Ember 2
    It runtime.js:4139
    Ember 3
    invoke queue.ts:201
    flush queue.ts:98
    flush deferred-action-queues.ts:75
    _end index.ts:616
    end index.ts:298
    _runExpiredTimers index.ts:739
    setTimeout handler*setTimeout platform.ts:50
    _installTimerTimeout index.ts:783
    _scheduleExpiredTimers index.ts:764
    _runExpiredTimers index.ts:738
watched-words.js:12

자세한 보고를 감사합니다. 누군가 확인해볼 수 있도록 알아보겠습니다. :slight_smile: :+1:

5개의 좋아요

@Arthri 님, 자세한 보고 감사합니다.

해당 문제가 수정되었습니다.

3개의 좋아요