Skip to content

Commit

Permalink
Merge pull request #98 from genkgo/ampersand_bug
Browse files Browse the repository at this point in the history
encode ampersands with quoted printable encoding
  • Loading branch information
frederikbosch authored Mar 18, 2022
2 parents 376fdf3 + 8728475 commit b6fd85d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Header/OptimalEncodedHeaderValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function __construct(string $value, bool $phrase = false)
'=?%s?Q?%s?=',
'UTF-8',
\preg_replace(
['/\?/', '/_/', '/(?<!^) /m'],
['=3F', '=5F', '_'],
['/\?/', '/_/', '/&/', '/(?<!^) /m'],
['=3F', '=5F', '=26', '_'],
(string) $encoded
)
)
Expand Down
15 changes: 15 additions & 0 deletions test/Unit/Header/SubjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public function it_encodes_underscores_with_quoted_printable_encoding(): void
);
}

/**
* @test
*/
public function it_encodes_ampersand_with_quoted_printable_encoding(): void
{
$subject = new Subject(
'Aaaaaaaaaaa 20 aaaaa Aaaaaaaaaaa ‘Aaaaaaaaaaaaaa Aaaaaaaa & Aaaaaaaaa’'
);

$this->assertEquals(
"=?UTF-8?Q?Aaaaaaaaaaa_20_aaaaa_Aaaaaaaaaaa_=E2=80=98Aaaaaaaaaaaaaa_Aaaaaaaa_=26?=\r\n =?UTF-8?Q?_Aaaaaaaaa=E2=80=99?=",
(string)$subject->getValue()
);
}

/**
* @return array
*/
Expand Down

0 comments on commit b6fd85d

Please sign in to comment.