commit f9345d316c22c3153a204ae36054f2902b445867
parent 4e33ec64402d7050d2ff788eb89ed5bd891a5be1
Author: Christoph Lohmann <20h@r-36.net>
Date: Mon, 21 May 2012 17:53:16 +0200
Adding some malformats of the wild Internet.
Diffstat:
mime.c | | | 29 | +++++++++++++++++++++-------- |
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/mime.c b/mime.c
@@ -78,14 +78,27 @@ mime_parsedate(char *str)
{
struct tm tim;
- bzero(&tim, sizeof(tim));
- if (strptime(str, "%a, %d %b %Y %T %z", &tim) == NULL) {
- if (strptime(str, "%a, %d %b %Y %T %Z", &tim) == NULL) {
- if (strptime(str, "%d %b %Y %T %z", &tim) == NULL) {
- return NULL;
- }
- }
- }
+ memset(&tim, 0, sizeof(tim));
+ if (strptime(str, "%a, %d %b %Y %T %z", &tim) != NULL)
+ return memdup(&tim, sizeof(tim));
+
+ if (!strncmp(str, "Date: ", 6))
+ str += 6;
+
+ /*
+ * Malformatted dates seen in the wild.
+ */
+ if (strptime(str, "%a, %d %b %Y %T %Z", &tim) != NULL)
+ return memdup(&tim, sizeof(tim));
+
+ if (strptime(str, "%d %b %Y %T %z", &tim) != NULL)
+ return memdup(&tim, sizeof(tim));
+
+ if (strptime(str, "%a, %d %b %Y, %T %z", &tim) != NULL)
+ return memdup(&tim, sizeof(tim));
+
+ if (strptime(str, "%d.%m.%Y", &tim) != NULL)
+ return memdup(&tim, sizeof(tim));
return memdup(&tim, sizeof(tim));
}