]> git.sur5r.net Git - openldap/commitdiff
ITS#2920 allow oid macro in ditcontentrule
authorHoward Chu <hyc@openldap.org>
Thu, 8 Apr 2004 21:51:50 +0000 (21:51 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 8 Apr 2004 21:51:50 +0000 (21:51 +0000)
libraries/libldap/schema.c

index 5f8db3196bf4881b1093bc646cc52c1c26b7c139..c413d1200d5f79fb4ea2a57258705b4f8a8ea33c 100644 (file)
@@ -2687,9 +2687,36 @@ ldap_str2contentrule( LDAP_CONST char * s,
        savepos = ss;
        cr->cr_oid = ldap_int_parse_numericoid(&ss,code,0);
        if ( !cr->cr_oid ) {
-               *errp = ss;
-               ldap_contentrule_free(cr);
-               return NULL;
+               if ( (flags & LDAP_SCHEMA_ALLOW_ALL) && (ss == savepos) ) {
+                       /* Backtracking */
+                       ss = savepos;
+                       kind = get_token(&ss,&sval);
+                       if ( kind == TK_BAREWORD ) {
+                               if ( !strcmp(sval, "NAME") ||
+                                    !strcmp(sval, "DESC") ||
+                                    !strcmp(sval, "OBSOLETE") ||
+                                    !strcmp(sval, "AUX") ||
+                                    !strcmp(sval, "MUST") ||
+                                    !strcmp(sval, "MAY") ||
+                                    !strcmp(sval, "NOT") ||
+                                    !strncmp(sval, "X-", 2) ) {
+                                       /* Missing OID, backtrack */
+                                       ss = savepos;
+                               } else if ( flags &
+                                       LDAP_SCHEMA_ALLOW_OID_MACRO ) {
+                                       /* Non-numerical OID, ignore */
+                                       int len = ss-savepos;
+                                       cr->cr_oid = LDAP_MALLOC(len+1);
+                                       strncpy(cr->cr_oid, savepos, len);
+                                       cr->cr_oid[len] = 0;
+                               }
+                       }
+                       LDAP_FREE(sval);
+               } else {
+                       *errp = ss;
+                       ldap_contentrule_free(cr);
+                       return NULL;
+               }
        }
        parse_whsp(&ss);