diff --git a/src/Header/GenericHeader.php b/src/Header/GenericHeader.php index 67834e93..cc48385a 100644 --- a/src/Header/GenericHeader.php +++ b/src/Header/GenericHeader.php @@ -76,9 +76,9 @@ public function setFieldName($fieldName) $fieldName = str_replace(' ', '-', ucwords(str_replace(array('_', '-'), ' ', $fieldName))); // Validate what we have - if (!preg_match('/^[a-z][a-z0-9-]*$/i', $fieldName)) { + if (!preg_match('/^[\x21-\x39\x3B-\x7E]*$/i', $fieldName)) { throw new Exception\InvalidArgumentException( - 'Header name must start with a letter, and consist of only letters, numbers and dashes.' + 'Header name must be composed of printable US-ASCII characters, except colon.' ); } diff --git a/src/Headers.php b/src/Headers.php index d62c7544..8e644edd 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -70,7 +70,7 @@ public static function fromString($string, $EOL = self::EOL) // iterate the header lines, some might be continuations foreach (explode($EOL, $string) as $line) { // check if a header name is present - if (preg_match('/^(?P[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $line, $matches)) { + if (preg_match('/^(?P[\x21-\x39\x3B-\x7E]+):.*$/', $line, $matches)) { if ($currentLine) { // a header name was present, then store the current complete line $headers->addHeaderLine($currentLine);