From 5962d965030a70a1cbf31081ed92d5f933e89c00 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Mar 08 2010 23:28:35 +0000 Subject: Bug 570905 - postalAddress syntax should allow empty lines (should allow $$) https://bugzilla.redhat.com/show_bug.cgi?id=570905 Resolves: bug 570905 Bug Description: postalAddress syntax should allow empty lines (should allow $$) Reviewed by: nhosoi (Thanks!) Branch: Directory_Server_8_2_Branch Fix Description: Even though RFC 4517 says a postal address syntax value should not contain empty lines (e.g. $$), most, if not all, current applications expect to be able to store $$. This adds an internal switch to allow support for $$ for now. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no (cherry picked from commit b8ff06dd240df947fee972fe13bb2826ebb02048) --- diff --git a/ldap/servers/plugins/syntaxes/cis.c b/ldap/servers/plugins/syntaxes/cis.c index 4a15e5e..284210f 100644 --- a/ldap/servers/plugins/syntaxes/cis.c +++ b/ldap/servers/plugins/syntaxes/cis.c @@ -79,6 +79,15 @@ static int oid_validate(struct berval *val); static int printable_validate(struct berval *val); /* + Even though the official RFC 4517 says that the postal syntax + line values must contain at least 1 character (i.e. no $$), it + seems that most, if not all, address book and other applications that + use postal address syntax values expect to be able to store empty + lines/values - so for now, allow it +*/ +static const int postal_allow_empty_lines = 1; + +/* * Attribute syntaxes. We treat all of these the same for now, even though * the specifications (e.g., RFC 2252) impose various constraints on the * the format for each of these. @@ -759,19 +768,14 @@ static int postal_validate( } else if (*p == '$') { /* This signifies the end of a line. We need * to ensure that the line is not empty. */ - if (p == start) { - rc = 1; - goto exit; - } - /* make sure the value doesn't end with a '$' */ - if (p == end) { - rc = 1; - goto exit; - } - - /* Make sure the line (start to p) is valid UTF-8. */ - if ((rc = utf8string_validate(start, p, NULL)) != 0) { + if ((p == start) || (p == end)) { + if (!postal_allow_empty_lines) { + rc = 1; + goto exit; + } /* else allow it */ + } else if ((rc = utf8string_validate(start, p, NULL)) != 0) { + /* Make sure the line (start to p) is valid UTF-8. */ goto exit; }