summaryrefslogtreecommitdiff
path: root/lib/gitlab/ldap/dn.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ldap/dn.rb')
-rw-r--r--lib/gitlab/ldap/dn.rb14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/gitlab/ldap/dn.rb b/lib/gitlab/ldap/dn.rb
index 555ef0b80ae..02a4cbcd13a 100644
--- a/lib/gitlab/ldap/dn.rb
+++ b/lib/gitlab/ldap/dn.rb
@@ -210,27 +210,19 @@ module Gitlab
# http://tools.ietf.org/html/rfc2253 section 2.4 lists these exceptions
# for dn values. All of the following must be escaped in any normal string
# using a single backslash ('\') as escape.
- ESCAPES = {
- ',' => ',',
- '+' => '+',
- '"' => '"',
- '\\' => '\\',
- '<' => '<',
- '>' => '>',
- ';' => ';',
- }
+ NORMAL_ESCAPES = [',', '+', '"', '\\', '<', '>', ';']
# Compiled character class regexp using the keys from the above hash, and
# checking for a space or # at the start, or space at the end, of the
# string.
ESCAPE_RE = Regexp.new("(^ |^#| $|[" +
- ESCAPES.keys.map { |e| Regexp.escape(e) }.join +
+ NORMAL_ESCAPES.map { |e| Regexp.escape(e) }.join +
"])")
##
# Escape a string for use in a DN value
def self.escape(string)
- string.gsub(ESCAPE_RE) { |char| "\\" + ESCAPES[char] }
+ string.gsub(ESCAPE_RE) { |char| "\\" + char }
end
##