Mercurial > hg > pnewss
diff 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 |
line wrap: on
line diff
--- a/dbreindex.php Tue Apr 12 11:41:35 2011 +0200 +++ b/dbreindex.php Tue Apr 12 14:10:41 2011 +0200 @@ -17,8 +17,13 @@ $headerchanged = FALSE; foreach (explode("\r\n", $article['header']) as $line) { if (!strlen($line) || $line == '.') { - print("Article $article[id] Contains empty or terminating header line\n"); + print("Article $article[id] Contains empty or terminating header line, fixing.\n"); + $headerchanged = TRUE; continue; + } else if (strpos($line, "\r") !== FALSE || strpos($line, "\n") !== FALSE || strpos($line, "\0")) { + print("Article $article[id] Contains invalid newline or NUL character in header, fixing.\n"); + $line = str_replace(array("\r","\n","\0"), '', $line); + $headerchanged = TRUE; } $parts = explode(': ', $line, 2); $headername = strtoupper($parts[0]); @@ -48,7 +53,13 @@ break; } } - foreach (explode("\r\n", $article['body']) as $line) if ($line == '.') print("Article $article[id] Contains terminating body line\n"); + foreach (explode("\r\n", $article['body']) as $line) { + if ($line == '.') { + print("Article $article[id] Contains terminating body line\n"); + } else if (strpos($line, "\r") !== FALSE || strpos($line, "\n") !== FALSE || strpos($line, "\0")) { + print("Article $article[id] Contains invalid newline or NUL character in body\n"); + } + } if (!isset($headers['NEWSGROUPS'])) { print("Article $article[id] Missing required Newsgroups header\n"); continue;