RFC 2849, "The LDAP Data Interchange Format (LDIF) - Technical Specification", June 2000Source of RFC: IETF - NON WORKING GROUP
Area Assignment: app
Errata ID: 4355
Publication Format(s) : TEXT
Reported By: Andrey Repin
Date Reported: 2015-05-05
Rejected by: Barry Leiba
Date Rejected: 2015-05-05
Throughout the document, when it says:
In the section "Formal Syntax Definition of LDIF", Notes 2 and 8 indirectly imply, that folded lines may contain leading whitespaces(1) and not allowed trailing whitespaces(2). Or, in other words, a fold must occur before a whitespace, or entire value must be base64-encoded before folding. However, the understanding is implied, rather than clearly stated.
It should say:
I suggest to clarify the folding rules to include a reference to trailing whitespaces in this specific case. Something as simple as "in case of folding a line containing whitespaces, the fold MUST NOT occur after a whitespace character" will go a long way towards clearing the confusion. Or, in ABNF syntax, folding-sequence = (SAFE-INIT-CHAR / ":" / "<") FILL SEP SPACE SAFE-CHAR (That is, symbols ":" and "<" may safely appear at the end of a value string, given it is not the first character of attribute value...)
The implication is drawn from the
(1): Note 2, "When joining folded lines, exactly one space character at the beginning of each continued line must be discarded." (Emphasis on "exactly one".)
(2): Note 8, "Values … that end with SPACE SHOULD be base-64 encoded.", implied premise of the format that each single line read from the file must be "basically correct", means, follow generic rule of (<empty line> / <comment> / <name:value pair> / <continuation line>) and the generic experience that trailing whitespaces are not apparently visible in text files without the use of special tools.
Except that it's an incorrect implication. The space at the beginning of the continued line is discarded simply because it's the space that was added to fold the line, so it has to be removed when you unfold. There is no restriction on where the folding is done other than what Note 2 says (MUST NOT fold before the first character of the line, and SHOULD NOT fold in the middle of a multi-byte UTF-8 character).
In particular, a line can be folded in the middle of a FILL sequence, in the middle of a sequence of SPACE characters in a string, or in the middle of a sequence of SPACE characters in a comment line. It is perfectly valid to have SPACE characters both before and after the <SEP SPACE> sequence that folding adds.