Fix trailing escaped newline
This commit is contained in:
parent
1480cf84d8
commit
26054114be
2 changed files with 3 additions and 3 deletions
|
@ -119,7 +119,7 @@ module Gitlab
|
||||||
when '0'..'9', 'a'..'f' then
|
when '0'..'9', 'a'..'f' then
|
||||||
state = :value_normal_escape_hex
|
state = :value_normal_escape_hex
|
||||||
hex_buffer = char
|
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
|
else state = :value_normal; value << char
|
||||||
end
|
end
|
||||||
when :value_normal_escape_hex then
|
when :value_normal_escape_hex then
|
||||||
|
@ -129,7 +129,7 @@ module Gitlab
|
||||||
value << "#{hex_buffer}#{char}".to_i(16).chr
|
value << "#{hex_buffer}#{char}".to_i(16).chr
|
||||||
else raise(MalformedDnError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"")
|
else raise(MalformedDnError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"")
|
||||||
end
|
end
|
||||||
when :value_normal_escape_space then
|
when :value_normal_escape_whitespace then
|
||||||
case char
|
case char
|
||||||
when '\\' then state = :value_normal_escape
|
when '\\' then state = :value_normal_escape
|
||||||
when ',' then
|
when ',' then
|
||||||
|
|
|
@ -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 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 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 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 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'
|
'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 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'
|
'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'
|
'converts an escaped hex equal sign to an escaped equal sign in an attribute value' | 'uid= foo \\3D bar' | 'uid=foo \\= bar'
|
||||||
|
|
Loading…
Reference in a new issue