Programming Language PHP

Namespace Elabftw\Services

Class Filter

Total Examples 12

12 code examples of PHP Elabftw\Services\Filter extracted from open source projects

Was this example useful?
0
                                                    public function testBody(): void
    {
        $this->assertEquals('my body', Filter::body('my body'));
        $this->assertEquals('my body', Filter::body('my body<script></script>'));
        $this->expectException(ImproperActionException::class);
        $body = str_repeat('a', 4120001);
        Filter::body($body);
    }
                                            
Was this example useful?
0
                                                    /**
     * Check the cookie token
     */
    public static function token(string $token): string
    {
        if (mb_strlen($token) !== self::COOKIE_LENGTH) {
            throw new IllegalActionException('Invalid cookie!');
        }
        return Filter::sanitize($token);
    }
                                            
Was this example useful?
0
                                                    private function getRealName(): string
    {
        // don't allow php extension
        $ext = Tools::getExt($this->content);
        if ($ext === 'php') {
            throw new ImproperActionException('No php extension allowed!');
        }
        return Filter::forFilesystem($this->content);
    }
                                            
Was this example useful?
0
                                                    public function getContent(): string
    {
        return Filter::tag($this->content);
    }
                                            
Was this example useful?
0
                                                    public function getContent(): string
    {
        return Filter::title($this->content);
    }
                                            
Was this example useful?
0
                                                    public function getBody(): string
    {
        return Filter::body($this->extra['body']);
    }
                                            
Was this example useful?
0
                                                    public function getExtraBody(): string
    {
        return Filter::body($this->extra['body'] ?? '');
    }
                                            
Was this example useful?
0
                                                    public function getDate(): string
    {
        return Filter::kdate($this->content);
    }
                                            
Was this example useful?
0
                                                    public function getTitle(): string
    {
        return Filter::title($this->content);
    }
                                            
Was this example useful?
0
                                                    public function getFilename(): string
    {
        return Filter::forFilesystem($this->realName);
    }
                                            
Was this example useful?
0
                                                    public function getExtra(string $key): string
    {
        return Filter::sanitize((string) $this->extra[$key]);
    }
                                            
Was this example useful?
0
                                                    public function getBody(): string
    {
        return Filter::body($this->content);
    }