mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 15:19:34 -05:00
Initial, very unforgiving, booleanValidate and booleanMatch.
This commit is contained in:
parent
e4a871d333
commit
8d4ec58151
1 changed files with 49 additions and 4 deletions
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
/* unimplemented validators */
|
/* unimplemented validators */
|
||||||
#define bitStringValidate NULL
|
#define bitStringValidate NULL
|
||||||
#define booleanValidate NULL
|
|
||||||
|
|
||||||
/* recycled normalization routines */
|
/* recycled normalization routines */
|
||||||
#define faxNumberNormalize numericStringNormalize
|
#define faxNumberNormalize numericStringNormalize
|
||||||
|
|
@ -32,10 +31,8 @@
|
||||||
|
|
||||||
/* unimplemented normalizers */
|
/* unimplemented normalizers */
|
||||||
#define bitStringNormalize NULL
|
#define bitStringNormalize NULL
|
||||||
#define booleanNormalize NULL
|
|
||||||
|
|
||||||
/* unimplemented pretters */
|
/* unimplemented pretters */
|
||||||
#define booleanPretty NULL
|
|
||||||
#define dnPretty NULL
|
#define dnPretty NULL
|
||||||
#define integerPretty NULL
|
#define integerPretty NULL
|
||||||
|
|
||||||
|
|
@ -301,6 +298,49 @@ blobValidate(
|
||||||
return LDAP_SUCCESS;
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handling boolean syntax and matching is quite rigid.
|
||||||
|
* A more flexible approach would be to allow a variety
|
||||||
|
* of strings to be normalized and prettied into TRUE
|
||||||
|
* and FALSE.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
booleanValidate(
|
||||||
|
Syntax *syntax,
|
||||||
|
struct berval *in )
|
||||||
|
{
|
||||||
|
/* very unforgiving validation, requires no normalization
|
||||||
|
* before simplistic matching
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( in->bv_len == 4 ) {
|
||||||
|
if( !memcmp( in->bv_val, "TRUE", 4 ) ) {
|
||||||
|
return LDAP_SUCCESS;
|
||||||
|
}
|
||||||
|
} else if( in->bv_len == 5 ) {
|
||||||
|
if( !memcmp( in->bv_val, "FALSE", 5 ) ) {
|
||||||
|
return LDAP_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return LDAP_INVALID_SYNTAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
booleanMatch(
|
||||||
|
int *matchp,
|
||||||
|
unsigned flags,
|
||||||
|
Syntax *syntax,
|
||||||
|
MatchingRule *mr,
|
||||||
|
struct berval *value,
|
||||||
|
void *assertedValue )
|
||||||
|
{
|
||||||
|
/* simplistic matching allowed by rigid validation */
|
||||||
|
struct berval *asserted = (struct berval *) assertedValue;
|
||||||
|
*matchp = value->bv_len != asserted->bv_len;
|
||||||
|
return LDAP_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
UTF8StringValidate(
|
UTF8StringValidate(
|
||||||
Syntax *syntax,
|
Syntax *syntax,
|
||||||
|
|
@ -1503,7 +1543,7 @@ struct syntax_defs_rec syntax_defs[] = {
|
||||||
{"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
|
{"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
|
||||||
0, bitStringValidate, bitStringNormalize, NULL },
|
0, bitStringValidate, bitStringNormalize, NULL },
|
||||||
{"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
|
{"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
|
||||||
0, booleanValidate, booleanNormalize, booleanPretty},
|
0, booleanValidate, NULL, NULL},
|
||||||
{"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
|
{"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
|
||||||
X_BINARY X_NOT_H_R ")",
|
X_BINARY X_NOT_H_R ")",
|
||||||
SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
|
SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
|
||||||
|
|
@ -1718,6 +1758,11 @@ struct mrule_defs_rec mrule_defs[] = {
|
||||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||||
NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
|
NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
|
||||||
|
|
||||||
|
{"( 2.5.13.13 NAME 'booleanMatch' "
|
||||||
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
|
||||||
|
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||||
|
NULL, NULL, booleanMatch, NULL, NULL},
|
||||||
|
|
||||||
{"( 2.5.13.14 NAME 'integerMatch' "
|
{"( 2.5.13.14 NAME 'integerMatch' "
|
||||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
|
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
|
||||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue