From 3fde6f6806dd86e3df4d08d55a63fed19f1dae55 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Wed, 20 Sep 2017 14:41:42 -0700 Subject: Fix trailing escaped space --- lib/gitlab/ldap/dn.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/gitlab/ldap/dn.rb b/lib/gitlab/ldap/dn.rb index 02a4cbcd13a..c23fac2d57a 100644 --- a/lib/gitlab/ldap/dn.rb +++ b/lib/gitlab/ldap/dn.rb @@ -115,6 +115,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 else state = :value_normal; value << char end when :value_normal_escape_hex then @@ -124,6 +125,16 @@ module Gitlab value << "#{hex_buffer}#{char}".to_i(16).chr else raise "DN badly formed" end + when :value_normal_escape_space then + case char + when '\\' then state = :value_normal_escape + when ',' then + state = :key + yield key.string.strip, value.string # Don't strip trailing escaped space! + key = StringIO.new + value = StringIO.new; + else value << char + end when :value_quoted then case char when '\\' then state = :value_quoted_escape -- cgit v1.2.1