Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Mail\Headers.php: Adjust regex for field name to RFC 5322 #4224

Closed
wants to merge 2 commits into from

2 participants

@Steffen185

According to RFC 5322 (http://tools.ietf.org/html/rfc5322#section-2.2), a field name may contain "printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon".

Steffen185 added some commits
@Steffen185 Steffen185 Mail\Headers.php: Adjust regex to RFC 5322
According to RFC 5322 (http://tools.ietf.org/html/rfc5322#section-2.2), a field name may contain "printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon".
569eaa2
@Steffen185 Steffen185 Mail\Header/GenericHeader.php: Adjust regex to RFC 5322 6f9fdc5
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4224'
Close #4224
ee0bd4d
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4224' into develop
Forward port #4224
48b60eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 14, 2013
  1. @Steffen185

    Mail\Headers.php: Adjust regex to RFC 5322

    Steffen185 authored
    According to RFC 5322 (http://tools.ietf.org/html/rfc5322#section-2.2), a field name may contain "printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon".
  2. @Steffen185
This page is out of date. Refresh to see the latest.
View
4 library/Zend/Mail/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.'
);
}
View
2  library/Zend/Mail/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<name>[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $line, $matches)) {
+ if (preg_match('/^(?P<name>[\x21-\x39\x3B-\x7E]+):.*$/', $line, $matches)) {
if ($currentLine) {
// a header name was present, then store the current complete line
$headers->addHeaderLine($currentLine);
Something went wrong with that request. Please try again.