Mercurial > hg > pnewss
comparison dbreindex.php @ 7:01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Tue, 12 Apr 2011 14:10:41 +0200 |
parents | bc6045ed0b2e |
children | 005339a1b2ce |
comparison
equal
deleted
inserted
replaced
6:bc6045ed0b2e | 7:01dc7eeaf5df |
---|---|
15 $headers = array(); | 15 $headers = array(); |
16 $header = array(); | 16 $header = array(); |
17 $headerchanged = FALSE; | 17 $headerchanged = FALSE; |
18 foreach (explode("\r\n", $article['header']) as $line) { | 18 foreach (explode("\r\n", $article['header']) as $line) { |
19 if (!strlen($line) || $line == '.') { | 19 if (!strlen($line) || $line == '.') { |
20 print("Article $article[id] Contains empty or terminating header line\n"); | 20 print("Article $article[id] Contains empty or terminating header line, fixing.\n"); |
21 $headerchanged = TRUE; | |
21 continue; | 22 continue; |
23 } else if (strpos($line, "\r") !== FALSE || strpos($line, "\n") !== FALSE || strpos($line, "\0")) { | |
24 print("Article $article[id] Contains invalid newline or NUL character in header, fixing.\n"); | |
25 $line = str_replace(array("\r","\n","\0"), '', $line); | |
26 $headerchanged = TRUE; | |
22 } | 27 } |
23 $parts = explode(': ', $line, 2); | 28 $parts = explode(': ', $line, 2); |
24 $headername = strtoupper($parts[0]); | 29 $headername = strtoupper($parts[0]); |
25 switch ($headername) { | 30 switch ($headername) { |
26 case 'PATH': case 'FROM': case 'NEWSGROUPS': case 'SUBJECT': case 'DATE': case 'MESSAGE-ID': case 'SENDER': | 31 case 'PATH': case 'FROM': case 'NEWSGROUPS': case 'SUBJECT': case 'DATE': case 'MESSAGE-ID': case 'SENDER': |
46 default: | 51 default: |
47 $header[] = $line; | 52 $header[] = $line; |
48 break; | 53 break; |
49 } | 54 } |
50 } | 55 } |
51 foreach (explode("\r\n", $article['body']) as $line) if ($line == '.') print("Article $article[id] Contains terminating body line\n"); | 56 foreach (explode("\r\n", $article['body']) as $line) { |
57 if ($line == '.') { | |
58 print("Article $article[id] Contains terminating body line\n"); | |
59 } else if (strpos($line, "\r") !== FALSE || strpos($line, "\n") !== FALSE || strpos($line, "\0")) { | |
60 print("Article $article[id] Contains invalid newline or NUL character in body\n"); | |
61 } | |
62 } | |
52 if (!isset($headers['NEWSGROUPS'])) { | 63 if (!isset($headers['NEWSGROUPS'])) { |
53 print("Article $article[id] Missing required Newsgroups header\n"); | 64 print("Article $article[id] Missing required Newsgroups header\n"); |
54 continue; | 65 continue; |
55 } | 66 } |
56 $newsgroups = array(); | 67 $newsgroups = array(); |