summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-09-20 17:16:57 -0700
committerMichael Kozono <mkozono@gmail.com>2017-10-07 10:28:13 -0700
commit26054114be8136137c4b3740c82b51f49027eaab (patch)
tree33fec5e97914e3c5f7bf737df104d507e13f680e
parent1480cf84d883552e952fdac834ad1da242b3dbcf (diff)
downloadgitlab-ce-26054114be8136137c4b3740c82b51f49027eaab.tar.gz
Fix trailing escaped newline
-rw-r--r--lib/gitlab/ldap/dn.rb4
-rw-r--r--spec/lib/gitlab/ldap/dn_spec.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/gitlab/ldap/dn.rb b/lib/gitlab/ldap/dn.rb
index 048b669b13a..557b5af118e 100644
--- a/lib/gitlab/ldap/dn.rb
+++ b/lib/gitlab/ldap/dn.rb
@@ -119,7 +119,7 @@ module Gitlab
when '0'..'9', 'a'..'f' then
state = :value_normal_escape_hex
hex_buffer = char
- when ' ' then state = :value_normal_escape_space; value << char
+ when /\s/ then state = :value_normal_escape_whitespace; value << char
else state = :value_normal; value << char
end
when :value_normal_escape_hex then
@@ -129,7 +129,7 @@ module Gitlab
value << "#{hex_buffer}#{char}".to_i(16).chr
else raise(MalformedDnError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"")
end
- when :value_normal_escape_space then
+ when :value_normal_escape_whitespace then
case char
when '\\' then state = :value_normal_escape
when ',' then
diff --git a/spec/lib/gitlab/ldap/dn_spec.rb b/spec/lib/gitlab/ldap/dn_spec.rb
index 1fd1aef1297..8c268645346 100644
--- a/spec/lib/gitlab/ldap/dn_spec.rb
+++ b/spec/lib/gitlab/ldap/dn_spec.rb
@@ -21,9 +21,9 @@ describe Gitlab::LDAP::DN do
'does not strip an escaped leading space in an attribute value' | 'uid=\\ John Smith,ou=People,dc=example,dc=com' | 'uid=\\ john smith,ou=people,dc=example,dc=com'
'does not strip an escaped trailing space in an attribute value' | 'uid=John Smith\\ ,ou=People,dc=example,dc=com' | 'uid=john smith\\ ,ou=people,dc=example,dc=com'
'does not strip an escaped leading newline in an attribute value' | 'uid=\\\nJohn Smith,ou=People,dc=example,dc=com' | 'uid=\\\njohn smith,ou=people,dc=example,dc=com'
- 'does not strip an escaped trailing newline in an attribute value' | 'uid=John Smith\\\n,ou=People,dc=example,dc=com' | 'uid=john smith\\\n,ou=people,dc=example,dc=com'
'does not strip an unescaped leading newline (actually an invalid DN)' | 'uid=\nJohn Smith,ou=People,dc=example,dc=com' | 'uid=\njohn smith,ou=people,dc=example,dc=com'
'does not strip an unescaped trailing newline (actually an invalid DN)' | 'uid=John Smith\n ,ou=People,dc=example,dc=com' | 'uid=john smith\n,ou=people,dc=example,dc=com'
+ 'hex-escapes and does not strip an escaped trailing newline in an attribute value' | "uid=John Smith\\\n,ou=People,dc=example,dc=com" | "uid=john smith\\0a,ou=people,dc=example,dc=com"
'does not strip if no extraneous whitespace' | 'uid=John Smith,ou=People,dc=example,dc=com' | 'uid=john smith,ou=people,dc=example,dc=com'
'does not modify an escaped equal sign in an attribute value' | 'uid= foo \\= bar' | 'uid=foo \\= bar'
'converts an escaped hex equal sign to an escaped equal sign in an attribute value' | 'uid= foo \\3D bar' | 'uid=foo \\= bar'