12 code examples of PHP Elabftw\Services\Filter extracted from open source projects
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);
}
/**
* 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);
}
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);
}
public function getContent(): string
{
return Filter::tag($this->content);
}
public function getContent(): string
{
return Filter::title($this->content);
}
public function getBody(): string
{
return Filter::body($this->extra['body']);
}
public function getExtraBody(): string
{
return Filter::body($this->extra['body'] ?? '');
}
public function getDate(): string
{
return Filter::kdate($this->content);
}
public function getTitle(): string
{
return Filter::title($this->content);
}
public function getFilename(): string
{
return Filter::forFilesystem($this->realName);
}
public function getExtra(string $key): string
{
return Filter::sanitize((string) $this->extra[$key]);
}
public function getBody(): string
{
return Filter::body($this->content);
}