[tin-dev] [tin 2.6.3] snapshots

Urs Janßen urs at tin.org
Tue Nov 7 13:11:21 CET 2023


Urs Janßen wrote:
> New snapshots available, incl.:

I screwed up damaged_id() which leads to too "agressive" shortened
References:lines. Heres the diff to rollback to the old version.

=== modified file 'src/post.c'
--- old/src/post.c	2023-11-07 08:49:52 +0000
+++ new/src/post.c	2023-11-07 12:03:06 +0000
@@ -3169,84 +3168,23 @@
 
 
 /*
- * Checks if Message-ID has valid format
+ * Checks if a (line of) Message-ID(s) has valid format
  * Returns FALSE if it does, TRUE if it does not
- * does NOT modify its input
- * does NOT accept trailing spaces
- *
- * see also refs.c:valid_msgid() which has swapped return
- * values, accepts trailing spaces and DOES modify its input
  */
 static t_bool
 damaged_id(
 	const char *id)
 {
-	signed int bracket = 0;
-	size_t mlen;
-	t_bool at_present = FALSE;
-
 	while (*id && isspace((unsigned char) *id))
 		id++;
 
-	mlen = strlen(id);
-
-	/* must start with '<' and have exactly one '>' (at the very end) */
-	if (mlen < 5 /* || mlen > 250 */ || *(id + mlen - 1) != '>' || strchr(id, '>') != (id + mlen - 1) || *id++ != '<')
+	if (*id != '<')
 		return TRUE;
 
-	while (*id) {
-		if (*id < 33 || *id > 126 || *id == '<' || *id == '\\' || (*id == '>' && *(id + 1) != '\0'))
-			return TRUE;
-
-		switch (*id) {
-			case '[':	/* '[' and ']' are only allowed in id-right */
-				if (bracket != 0 || !at_present || *(id - 1) != '@' || strchr(id, '@'))
-					return TRUE;
-				else
-					bracket++;
-				break;
-
-			case ']':
-				if (bracket != 1 || !at_present || *(id + 1) != '>')
-					return TRUE;
-				else
-					bracket--;
-				break;
-
-			case '@':
-				if (!at_present) {
-					if (*(id + 1) == '.')
-						return TRUE;
-
-					at_present = TRUE;
-				} else {	/* multiple '@' are only ok inside [] */
-					if (!bracket)
-						return TRUE;
-				}
-				break;
-
-			case '.':
-				if (*(id + 1) == '.' || *(id + 1) == '@' || *(id + 1) == '>' || *(id + 1) == ']' || *(id - 1) == '<')
-					return TRUE;
-				break;
-
-			case '(':
-			case ')':
-			case ':':
-			case ';':
-			case ',':
-			case '"':
-				if (!bracket)
-					return TRUE;
-				break;
-
-			default:
-				break;
-		}
+	while (isascii((unsigned char) *id) && isgraph((unsigned char) *id) && !iscntrl((unsigned char) *id) && *id != '>')
 		id++;
-	}
 
-	if (bracket != 0 || !at_present)
+	if (*id != '>')
 		return TRUE;
 
 	return FALSE;




More information about the tin-dev mailing list