#include "lib.h"
#include "array.h"
#include "str.h"
+#include "unichar.h"
/* <settings checks> */
#include "strescape.h"
/* </settings checks> */
#include "acl-api-private.h"
+#include <ctype.h>
+
/* <settings checks> */
const struct acl_letter_map acl_letter_map[] = {
{ 'l', MAIL_ACL_LOOKUP },
/* </settings checks> */
+bool acl_id_is_valid(const char *id)
+{
+ size_t len = strlen(id);
+
+ if (len > ACL_ID_MAX_LEN)
+ return FALSE;
+ for (size_t i = 0; i < len; i++) {
+ if (i_iscntrl(id[i]))
+ return FALSE;
+ }
+ return uni_utf8_data_is_valid((const unsigned char *)id, len);
+}
+
void acl_rights_write_id(string_t *dest, const struct acl_rights *right)
{
switch (right->id_type) {
#define ACL_ID_NAME_GROUP_PREFIX "group="
#define ACL_ID_NAME_GROUP_OVERRIDE_PREFIX "group-override="
+#define ACL_ID_MAX_LEN 1024
+
struct acl_letter_map {
const char letter;
const char *name;
time_t last_change;
};
+/* Returns TRUE if the ACL identifier string is valid: no longer than
+ ACL_ID_MAX_LEN bytes, no control characters and valid UTF-8. */
+bool acl_id_is_valid(const char *id);
+
/* Returns the canonical ID for the right. */
const char *acl_rights_get_id(const struct acl_rights *right);