Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

QpMimeHeaderEncoder.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Mime\Encoder;
  11. /**
  12. * @author Chris Corbyn
  13. *
  14. * @experimental in 4.3
  15. */
  16. final class QpMimeHeaderEncoder extends QpEncoder implements MimeHeaderEncoderInterface
  17. {
  18. protected function initSafeMap(): void
  19. {
  20. foreach (array_merge(
  21. range(0x61, 0x7A), range(0x41, 0x5A),
  22. range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F]
  23. ) as $byte) {
  24. $this->safeMap[$byte] = \chr($byte);
  25. }
  26. }
  27. public function getName(): string
  28. {
  29. return 'Q';
  30. }
  31. public function encodeString(string $string, ?string $charset = 'utf-8', int $firstLineOffset = 0, int $maxLineLength = 0): string
  32. {
  33. return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"],
  34. parent::encodeString($string, $charset, $firstLineOffset, $maxLineLength)
  35. );
  36. }
  37. }