Server IP : / Your IP : 10.244.4.16 [ Web Server : nginx/1.25.3 System : Linux escuela-portal-app-54f56585bc-kst6g 5.15.0-1084-azure #93-Ubuntu SMP Sat Mar 15 14:12:29 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.2.13 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /proc/449/cwd/app/vendor/egulias/email-validator/src/Parser/ |
Upload File : |
<?php namespace Egulias\EmailValidator\Parser; use Egulias\EmailValidator\EmailLexer; use Egulias\EmailValidator\Warning\CFWSNearAt; use Egulias\EmailValidator\Result\InvalidEmail; use Egulias\EmailValidator\Warning\CFWSWithFWS; use Egulias\EmailValidator\Result\Reason\CRNoLF; use Egulias\EmailValidator\Result\Reason\AtextAfterCFWS; use Egulias\EmailValidator\Result\Reason\CRLFAtTheEnd; use Egulias\EmailValidator\Result\Reason\CRLFX2; use Egulias\EmailValidator\Result\Reason\ExpectingCTEXT; use Egulias\EmailValidator\Result\Result; use Egulias\EmailValidator\Result\ValidEmail; class FoldingWhiteSpace extends PartParser { public const FWS_TYPES = [ EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::S_CR, EmailLexer::S_LF, EmailLexer::CRLF ]; public function parse() : Result { if (!$this->isFWS()) { return new ValidEmail(); } $previous = $this->lexer->getPrevious(); $resultCRLF = $this->checkCRLFInFWS(); if ($resultCRLF->isInvalid()) { return $resultCRLF; } if (((array) $this->lexer->token)['type'] === EmailLexer::S_CR) { return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { return new InvalidEmail(new AtextAfterCFWS(), ((array) $this->lexer->token)['value']); } if (((array) $this->lexer->token)['type'] === EmailLexer::S_LF || ((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) { return new InvalidEmail(new ExpectingCTEXT(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); } else { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); } return new ValidEmail(); } protected function checkCRLFInFWS() : Result { if (((array) $this->lexer->token)['type'] !== EmailLexer::CRLF) { return new ValidEmail(); } if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { return new InvalidEmail(new CRLFX2(), ((array) $this->lexer->token)['value']); } //this has no coverage. Condition is repeated from above one if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { return new InvalidEmail(new CRLFAtTheEnd(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } protected function isFWS() : bool { if ($this->escaped()) { return false; } return in_array(((array) $this->lexer->token)['type'], self::FWS_TYPES); } }