summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/plugins/special-use/ext-special-use-common.c
blob: fcaf1b57d7b7e923fa81cef2b3b14d2f6c07b99e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Copyright (c) 2019 Pigeonhole authors, see the included COPYING file */

#include "lib.h"
#include "imap-arg.h"

#include "ext-special-use-common.h"

bool ext_special_use_flag_valid(const char *flag)
{
	const char *p = flag;

	/* RFC 6154, Section 6:

	   use-attr        =  "\All" / "\Archive" / "\Drafts" / "\Flagged" /
	                      "\Junk" / "\Sent" / "\Trash" / use-attr-ext
	   use-attr-ext    =  "\" atom
	 */

	/* "\" */
	if (*p != '\\')
		return FALSE;
	p++;

	/* atom */
	for (; *p != '\0'; p++) {
		if (!IS_ATOM_CHAR(*p))
			return FALSE;
	}

	return TRUE;
}