]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Fix and improve how tokens are recognised for conditionals etc..
authorBen Schmidt <none@none>
Fri, 20 Apr 2012 00:41:58 +0000 (10:41 +1000)
committerBen Schmidt <none@none>
Fri, 20 Apr 2012 00:41:58 +0000 (10:41 +1000)
README.listtexts
src/prepstdreply.c

index ac7dbabf39d77c13d3dda9f571bb6fe04238d504..cb0a38e43a48d841af9ef11736c06b2b47ed1ab3 100644 (file)
@@ -341,13 +341,13 @@ appropriate for use in headers. They are:
 
 - %text T%
   text from the file named T in the listdir/text directory; the name may only
-  include letters, digits, underscore, dot and hyphen; note that there is an
-  unformatted version of this directive
+  include letters, digits, underscore, dot and hyphen, and may not start with a
+  dot; note that there is an unformatted version of this directive
 
 - %control C%
   the contents of the control file named C in listir/control; the name may only
-  include letters, digits, underscore, dot and hyphen; note that there is an
-  unformatted version of this directive
+  include letters, digits, underscore, dot and hyphen, and may not start with a
+  dot; note that there is an unformatted version of this directive
 
 - %originalmail%
 - %originalmail N%
@@ -418,7 +418,8 @@ Unformatted substitutions that are available are:
 - $control C$
   the contents of the control file named C in listdir/control, with its final
   newline stripped; the name may only include letters, digits, underscore, dot
-  and hyphen; note that there is a formatted version of this directive
+  and hyphen, and may not start with a dot; note that there is a formatted
+  version of this directive
 
 - $digestfirst$
   (available only in digest)
@@ -562,7 +563,8 @@ Unformatted substitutions that are available are:
 - $text T$
   text from the file named T in the listdir/text directory, with its final
   newline stripped; the name may only include letters, digits, underscore, dot
-  and hyphen; note that there is a formatted version of this directive
+  and hyphen, and may not start with a dot; note that there is a formatted
+  version of this directive
 
 Escapes
 -------
index bd47c5b8d7dae3e444bfa4441d3610f47cba54de..1f46e3b78d53d06593e6b1f24205bb379b3a3096 100644 (file)
@@ -298,14 +298,14 @@ void finish_file_lines(file_lines_state *s)
 
 static char *filename_token(char *token)
 {
-       char *pos;
-       if (*token == '\0') return NULL;
-       pos = token;
+       char *pos = token;
+       if (*pos == '\0') return NULL;
        while (
                (*pos >= '0' && *pos <= '9') ||
                (*pos >= 'A' && *pos <= 'Z') ||
                (*pos >= 'a' && *pos <= 'z') ||
-               (*pos == '_') || (*pos == '-') || (*pos == '.')
+               (*pos == '_') || (*pos == '-') ||
+               (*pos == '.' && pos != token)
        ) {
                pos++;
        }
@@ -736,18 +736,17 @@ static int handle_conditional(text *txt, char **line_p, char **pos_p,
        conditional *cond;
 
        if (txt->skip == NULL) {
-               pos = token;
                for (;;) {
-                       if (*token == '\0') break;
-                       for (; *pos != '\0' && (!multi || *pos != ' ');
-                                       pos++) {
-                               if(*pos >= '0' && *pos <= '9') continue;
-                               if(*pos >= 'A' && *pos <= 'Z') continue;
-                               if(*pos >= 'a' && *pos <= 'z') continue;
-                               if(*pos == '_') continue;
-                               if(*pos == '-') continue;
-                               if(*pos == '.') continue;
-                               break;
+                       pos = token;
+                       if (*pos == '\0') break;
+                       while (
+                               (*pos >= '0' && *pos <= '9') ||
+                               (*pos >= 'A' && *pos <= 'Z') ||
+                               (*pos >= 'a' && *pos <= 'z') ||
+                               (*pos == '_') || (*pos == '-') ||
+                               (*pos == '.' && pos != token)
+                       ) {
+                               pos++;
                        }
                        if (*pos == ' ') {
                                *pos = '\0';
@@ -780,7 +779,7 @@ static int handle_conditional(text *txt, char **line_p, char **pos_p,
 
                        if (!multi) break;
                        *pos = ' ';
-                       pos++;
+                       token = pos + 1;
                }
        } else {
                /* We consider nested conditionals as successful while skipping