- case '=':
- case '+':
- {
- /* if folder = imap[s]://host/: don't append slash */
- if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
- Maildir[m_strlen(Maildir) - 1] == '/')
- m_strcpy(p, sizeof(p), NONULL(Maildir));
- else
- snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
-
- tail = s + 1;
- }
- break;
-
- /* elm compatibility, @ expands alias to user name */
-
- case '@':
- {
- HEADER *h;
- /* FIXME: BUG ? */
- address_t *alias;
-
- if ((alias = alias_lookup(s + 1))) {
- h = header_new();
- h->env = envelope_new();
- h->env->from = h->env->to = alias;
- mutt_default_save (p, sizeof (p), h);
- h->env->from = h->env->to = NULL;
- header_delete(&h);
- /* Avoid infinite recursion if the resulting folder starts with '@' */
- if (*p != '@')
- recurse = 1;
-
- tail = "";
- }
- }
- break;
-
- case '>':
- {
- m_strcpy(p, sizeof(p), NONULL(Inbox));
- tail = s + 1;
- }
- break;
-
- case '<':
- {
- m_strcpy(p, sizeof(p), NONULL(Outbox));
- tail = s + 1;
- }
- break;
-
- case '!':
- {
- if (*(s + 1) == '!') {
- m_strcpy(p, sizeof(p), NONULL(LastFolder));
- tail = s + 2;
- }
- else {
- m_strcpy(p, sizeof(p), NONULL(Spoolfile));
- tail = s + 1;
- }
- }
- break;
-
- case '-':
- {
- m_strcpy(p, sizeof(p), NONULL(LastFolder));
- tail = s + 1;
- }
- break;
-
- case '^':
- {
- m_strcpy(p, sizeof(p), NONULL(CurrentFolder));
- tail = s + 1;
- }
- break;
-
- default:
- {
- *p = '\0';
- tail = s;
- }
- }
-
- if (rx && *p && !recurse) {
- rx_sanitize_string (q, sizeof (q), p);
- snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
+ if (rx) {
+ char q[_POSIX_PATH_MAX];
+ rx_sanitize_string(q, sizeof(q), p);
+ snprintf(tmp, sizeof(tmp), "%s%s", q, tail);
+ } else {
+ snprintf(tmp, sizeof(tmp), "%s%s", p, tail);