Commit: 9c3e92ce0de4d368b7638cf442da781a0251225a Author: Ben Ramsey <[email protected]> Tue, 5 Jan 2016 18:09:09 -0600 Parents: aae3e0e43338be6c026c7a0eccc718f19d96c0ce Branches: master
Link: http://git.php.net/?p=web/news.git;a=commitdiff;h=9c3e92ce0de4d368b7638cf442da781a0251225a Log: Fix undefined index notices Changed paths: M article.php M getpart.php Diff: diff --git a/article.php b/article.php index a50f824..7e40ce7 100644 --- a/article.php +++ b/article.php @@ -76,21 +76,23 @@ while (!feof($s)) { $started = 1; } - $encoding = strtolower(trim(@$headers['content-transfer-encoding'])); + if (!empty($headers['content-transfer-encoding'])) { + $encoding = strtolower(trim($headers['content-transfer-encoding'])); + } if (strlen($mimetype) && $mimetype != "text/plain" && substr($mimetype,0,10) != "multipart/") { # Display a link to the attachment $name = ''; - if ($headers['content-type'] + if (!empty($headers['content-type']) && preg_match('/name=(["\']?)(.+)\1/s', $headers['content-type'], $m)) { $name = trim($m[2]); - } else if ($headers['content-disposition'] - && preg_match('/filename=(["\']?)(.+)\1/s', $headers['content-type'], $m)) { + } else if (!empty($headers['content-disposition']) + && preg_match('/filename=(["\']?)(.+)\1/s', $headers['content-disposition'], $m)) { $name = trim($m[2]); } - if ($headers['content-description']) { + if (!empty($headers['content-description'])) { $description = trim($headers['content-description']) . " "; } else { $description = ''; @@ -266,7 +268,7 @@ function start_article($group, $headers, $charset) { echo "</td>\n"; } # groups - if ($headers["newsgroups"]) { + if (!empty($headers["newsgroups"])) { echo ' <td class="headerlabel">Groups:</td>' . "\n"; echo ' <td class="headervalue">'; $r = explode(",", chop($headers["newsgroups"])); diff --git a/getpart.php b/getpart.php index f354960..815b4cd 100644 --- a/getpart.php +++ b/getpart.php @@ -51,23 +51,25 @@ while (!feof($s)) { } if ($inheaders && ($line == "\n" || $line == "\r\n")) { $inheaders = 0; - if ($headers['content-type'] + if (!empty($headers['content-type']) && preg_match("/charset=(\"|'|)(.+)\\1/is", $headers['content-type'], $m)) { $charset = trim($m[2]); } - if ($headers['content-type'] + if (!empty($headers['content-type']) && preg_match("/boundary=(\"|'|)(.+)\\1/is", $headers['content-type'], $m)) { $boundaries[] = trim($m[2]); $boundary = end($boundaries); } - if ($headers['content-type'] + if (!empty($headers['content-type']) && preg_match("/([^;]+)(;|\$)/", $headers['content-type'], $m)) { ++$mimecount; } $emit = ($mimecount == $part); - $encoding = strtolower(trim($headers['content-transfer-encoding'])); + if (!empty($headers['content-transfer-encoding'])) { + $encoding = strtolower(trim($headers['content-transfer-encoding'])); + } if ($emit) { /* check if content-type exist is made above */ header('Content-Type: ' . $headers['content-type']); -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
