{"record":{"id":"531b8874a189e5c1","repo":"jstedfast/MailKit","slug":"annotation-attribute-specifiers-cannot-contain-or","errorCode":null,"errorMessage":"Annotation attribute specifiers cannot contain '*' or '%'.","messagePattern":"Annotation attribute specifiers cannot contain '\\*' or '%'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/AnnotationAttribute.cs","lineNumber":124,"sourceCode":"\t\t/// </remarks>\n\t\t/// <param name=\"specifier\">The annotation attribute specifier.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"specifier\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\t/// <exception cref=\"System.ArgumentException\">\n\t\t/// <paramref name=\"specifier\"/> contains illegal characters.\n\t\t/// </exception>\n\t\tpublic AnnotationAttribute (string specifier)\n\t\t{\n\t\t\tif (specifier == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (specifier));\n\n\t\t\tif (specifier.Length == 0)\n\t\t\t\tthrow new ArgumentException (\"Annotation attribute specifiers cannot be empty.\", nameof (specifier));\n\n\t\t\t// TODO: improve validation\n\t\t\tif (specifier.IndexOfAny (Wildcards) != -1)\n\t\t\t\tthrow new ArgumentException (\"Annotation attribute specifiers cannot contain '*' or '%'.\", nameof (specifier));\n\n\t\t\tSpecifier = specifier;\n\n\t\t\tif (specifier.EndsWith (\".shared\", StringComparison.Ordinal)) {\n\t\t\t\tName = specifier.Substring (0, specifier.Length - \".shared\".Length);\n\t\t\t\tScope = AnnotationScope.Shared;\n\t\t\t} else if (specifier.EndsWith (\".priv\", StringComparison.Ordinal)) {\n\t\t\t\tName = specifier.Substring (0, specifier.Length - \".priv\".Length);\n\t\t\t\tScope = AnnotationScope.Private;\n\t\t\t} else {\n\t\t\t\tScope = AnnotationScope.Both;\n\t\t\t\tName = specifier;\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Get the name of the annotation attribute.\n\t\t/// </summary>","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AnnotationAttribute.cs#L106-L142","documentation":"The AnnotationAttribute constructor throws ArgumentException when the specifier contains IMAP mailbox wildcards '*' or '%'. Attribute specifiers name attributes of an entry, not mailboxes, so wildcard characters are rejected (validation is intentionally minimal — see the TODO in the source).","triggerScenarios":"Calling `new AnnotationAttribute(\"/priv*\")` or passing a mailbox-style pattern (e.g. \"%\", \"INBOX*\", strings copied from mailbox wildcard matching code) as an attribute specifier.","commonSituations":"Confusing IMAP mailbox wildcards (used in folder listing) with annotation entry/attribute specifiers; building a specifier by concatenating a user-supplied pattern.","solutions":["Remove any '*' or '%' characters from the specifier before constructing AnnotationAttribute.","Use the correct literal attribute names (e.g. \"/private/comment\", \"value.privacy\").","If wildcard matching is intended, that belongs in entry-selector/matching logic, not the attribute specifier."],"exampleFix":"// before\nvar attr = new AnnotationAttribute(\"/private/*\");\n// after\nvar attr = new AnnotationAttribute(\"/private/comment\");","handlingStrategy":"validation","validationCode":"if (specifier.IndexOfAny(new[] {'*','%'}) != -1)\n    throw new FormatException(\"Attribute specifier must not contain IMAP wildcards\");\nvar attr = new AnnotationAttribute(specifier);","typeGuard":"bool IsValidSpecifier(string s) => !string.IsNullOrEmpty(s) && s.IndexOfAny(new[] {'*','%'}) == -1;","tryCatchPattern":"try\n{\n    var attr = new AnnotationAttribute(specifier);\n}\ncatch (ArgumentException)\n{\n    // strip wildcards or use the literal attribute name\n    specifier = specifier.Replace(\"*\", \"\").Replace(\"%\", \"\");\n}","preventionTips":["Do not reuse mailbox wildcard patterns as attribute specifiers.","Keep a whitelist of valid attribute names (\"/private\", \"/shared\", \"value\", etc.).","Sanitize user input before it reaches the constructor."],"tags":["mailkit","imap","annotations","wildcards"],"backgroundTag":"invalid-argument-value","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}