Menu

#3 Subtle error in LDIF processing

open
nobody
None
5
2005-12-17
2005-12-17
Anonymous
No

It is (apparently) legal to have attributes named 'delete', though arguably
bad design. I inhereted such a schema, and the LDIF parser treated the
'delete' attibute as a directive, even though there was no preceding
'changetype', and raised an error.

I corrected for this by modifying LDAP::LDIF.parse_entry() as follows:

(starting on line 262 in version 1.11)

when 'add', 'delete', 'replace'
if change_type == LDAP_MOD_REPLACE
mod_type = case attr
when 'add' then LDAP_MOD_ADD
when 'delete' then LDAP_MOD_DELETE
when 'replace' then LDAP_MOD_REPLACE
end

mods[mod_type] ||= {}
mods[mod_type][val] ||= []
else
hash[attr] ||= []
hash[attr] << val
comment = false

# Make a note of this attribute if value is binary.
bvalues << attr if unsafe_char?( val )
end

It's not very DRY. I'm sure it can be handled better.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.