- strncpy(fullname, cp, sizeof(fullname));
-
- if (strchr(fullname, '.')) { /* quote any .'s */
- char tmp[BUFSIZ];
-
- /* should quote "'s too */
- snprintf(tmp, sizeof(tmp), "\"%s\"", fullname);
- strncpy(fullname, tmp, sizeof(fullname));
+ strncpy(tmp, cp, sizeof(tmp));
+
+ /* quote the fullname as needed */
+ needquotes = 0;
+ for (tp=tmp; *tp; tp++) {
+ switch (*tp) {
+ case '(': case ')': case '<': case '>': case '[': case ']':
+ case ':': case ';': case '@': case '\\': case ',': case '.':
+ case '"': /* cf. RFC 5322 */
+ break; /* ... the switch */
+ default:
+ continue; /* ... the loop */
+ }
+ /* we've found a special char */
+ needquotes = 1;
+ break;