![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/laminas/laminas-mail/src/Header/ |
<?php namespace Laminas\Mail\Header; use function ord; use function strlen; final class HeaderName { /** * No public constructor. */ private function __construct() { } /** * Filter the header name according to RFC 2822 * * @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2) * * @param string $name * @return string */ public static function filter($name) { $result = ''; $tot = strlen($name); for ($i = 0; $i < $tot; $i += 1) { $ord = ord($name[$i]); if ($ord > 32 && $ord < 127 && $ord !== 58) { $result .= $name[$i]; } } return $result; } /** * Determine if the header name contains any invalid characters. * * @param string $name * @return bool */ public static function isValid($name) { $tot = strlen($name); for ($i = 0; $i < $tot; $i += 1) { $ord = ord($name[$i]); if ($ord < 33 || $ord > 126 || $ord === 58) { return false; } } return true; } /** * Assert that the header name is valid. * * Raises an exception if invalid. * * @param string $name * @throws Exception\RuntimeException * @return void */ public static function assertValid($name) { if (! self::isValid($name)) { throw new Exception\RuntimeException('Invalid header name detected'); } } }