php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch linux-line-endings-message-body-and-utf-8-parsing-fix.patch.txt for Website problem Bug #54077

Patch version 2011-02-23 11:20 UTC

Return to Bug #54077 | Download this patch
Patch Revisions:

Developer: shein@php.net

Index: article.php
===================================================================
--- article.php	(revision 307013)
+++ article.php	(working copy)
@@ -47,7 +47,7 @@
 	if ($inheaders && ($line == "\n" || $line == "\r\n")) {
 		$inheaders = 0;
 		if (isset($headers['content-type'])) {
-			if (preg_match('/charset=(["\']?)(\w+)\1/i', $headers['content-type'], $m)) {
+			if (preg_match('/charset=(["\']?)([\w-]+)\1/i', $headers['content-type'], $m)) {
 				$charset = trim($m[2]);
 			}
 		
@@ -161,7 +161,7 @@
 
 		$line = $linebuf . $line;
 
-		if (substr($line, -2) == "\r\n") {
+		if (in_array(substr($line, -1), array("\n", "\r"))) {
 		   $linebuf = '';
 		} else {
 		   $linebuf = $line;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 22:01:31 2024 UTC