phpBB

Code Changes

File: phpbb/textformatter/s9e/parser.php

  Unmodified   Added   Modified   Removed
Line 13Line 13

namespace phpbb\textformatter\s9e;



namespace phpbb\textformatter\s9e;


use s9e\TextFormatter\Parser\BuiltInFilters;

use s9e\TextFormatter\Parser\AttributeFilters\UrlFilter;

use s9e\TextFormatter\Parser\Logger;

use s9e\TextFormatter\Parser\Logger;

 
use s9e\TextFormatter\Parser\Tag;


/**
* s9e\TextFormatter\Parser adapter


/**
* s9e\TextFormatter\Parser adapter

Line 142Line 143
	public function disable_smilies()
{
$this->parser->disablePlugin('Emoticons');

	public function disable_smilies()
{
$this->parser->disablePlugin('Emoticons');

 
		$this->parser->disablePlugin('Emoji');

	}

/**

	}

/**

Line 183Line 185
	public function enable_smilies()
{
$this->parser->enablePlugin('Emoticons');

	public function enable_smilies()
{
$this->parser->enablePlugin('Emoticons');

 
		$this->parser->enablePlugin('Emoji');

	}

/**

	}

/**

Line 194Line 197
	public function get_errors()
{
$errors = array();

	public function get_errors()
{
$errors = array();

		foreach ($this->parser->getLogger()->get() as $entry)

		foreach ($this->parser->getLogger()->getLogs() as $entry)

		{
list(, $msg, $context) = $entry;


		{
list(, $msg, $context) = $entry;


Line 217Line 220
			{
$errors[] = array($msg, $context['max_' . strtolower($m[1])]);
}

			{
$errors[] = array($msg, $context['max_' . strtolower($m[1])]);
}

			else if ($msg === 'Tag is disabled')

			else if ($msg === 'Tag is disabled' && $this->is_a_bbcode($context['tag']))

			{
$name = strtolower($context['tag']->getName());
$errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']');

			{
$name = strtolower($context['tag']->getName());
$errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']');

Line 340Line 343
			return false;
}


			return false;
}


		if ($size < 1)

		if ($size < 1 || !is_numeric($size))

		{
return false;
}

		{
return false;
}

Line 363Line 366
	static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width)
{
// Validate the URL

	static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width)
{
// Validate the URL

		$url = BuiltInFilters::filterUrl($url, $url_config, $logger);

		$url = UrlFilter::filter($url, $url_config, $logger);

		if ($url === false)
{
return false;

		if ($url === false)
{
return false;

Line 393Line 396
		}

return $url;

		}

return $url;

 
	}

/**
* Test whether given tag consumes text that looks like BBCode-styled markup
*
* @param Tag $tag Original tag
* @return bool
*/
protected function is_a_bbcode(Tag $tag)
{
if ($tag->getLen() < 3)
{
return false;
}
$markup = substr($this->parser->getText(), $tag->getPos(), $tag->getLen());

return (bool) preg_match('(^\\[\\w++.*?\\]$)s', $markup);

	}
}


	}
}