cvs: php-news-web / article.php
| From: | Sean Coates | Date: | Wed, 26 Jan 2005 19:08:25 +0000 |
| Subject: | cvs: php-news-web / article.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-27331@lists.php.net to get a copy of this message | ||
sean Wed Jan 26 14:08:25 2005 EDT
Modified files:
/php-news-web article.php
Log:
fixed line-breaking problem (broken quote colours and URL regex)
http://cvs.php.net/diff.php/php-news-web/article.php?r1=1.30&r2=1.31&ty=u
Index: php-news-web/article.php
diff -u php-news-web/article.php:1.30 php-news-web/article.php:1.31
--- php-news-web/article.php:1.30 Wed Jan 26 12:35:52 2005
+++ php-news-web/article.php Wed Jan 26 14:08:25 2005
@@ -39,10 +39,9 @@
$mimecount = 0; // number of mime parts
$boundaries = array();
$lk = '';
-$prevquote = 0;
-$prevline = '';
+$linebuf = '';
while (!feof($s)) {
- $line = fgets($s, 4096);
+ $line = fgets($s);
if ($line == ".\r\n") break;
if ($inheaders && ($line == "\n" || $line == "\r\n")) {
$inheaders = 0;
@@ -107,6 +106,7 @@
$line = substr($line,1);
}
+
if ($inheaders) {
list($k,$v) = explode(": ", $line, 2);
if ($k && $v) {
@@ -153,6 +153,15 @@
$line = to_utf8($line, $charset);
}
+ $line = $linebuf . $line;
+
+ if (substr($line, -2) == "\r\n") {
+ $linebuf = '';
+ } else {
+ $linebuf = $line;
+ continue;
+ }
+
# this is some amazingly simplistic code to color quotes/signatures
# differently, and turn links into real links. it actually appears
# to work fairly well, but could easily be made more sophistimicated.
@@ -166,17 +175,11 @@
echo "</span>";
$insig = 0;
}
- if (
- (!$insig && substr($line,0,4) == ">") ||
- ($prevquote && !in_array(substr($prevline, -1), array("\r","\n")))
- ) {
+ if (!$insig && substr($line,0,4) == ">") {
echo "<span class=\"quote\">$line</span>";
- $prevquote = 1;
} else {
echo $line;
- $prevquote = 0;
}
- $prevline = $line;
}
}
if ($inheaders && !$started) {