summaryrefslogtreecommitdiff
path: root/lib/gitlab/unicode.rb
blob: f291ea1b4eeda41c50d698ba8047e3d92d8f4347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Gitlab
  class Unicode
    # Regular expression for identifying bidirectional control
    # characters in UTF-8 strings
    #
    # Documentation on how this works:
    # https://idiosyncratic-ruby.com/41-proper-unicoding.html
    BIDI_REGEXP = /\p{Bidi Control}/.freeze

    # Regular expression for identifying space characters
    #
    # In web browsers space characters can be confused with simple
    # spaces which may be misleading
    SPACE_REGEXP = /\p{Space_Separator}/.freeze

    class << self
      # Warning message used to highlight bidi characters in the GUI
      def bidi_warning
        _("Potentially unwanted character detected: Unicode BiDi Control")
      end
    end
  end
end