<commit_before><?php
/**
 * This file is part of the Atline templating system package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Copyright (c) 2015 - 2016 by <NAME>
 *
 * @license   MIT License
 * @copyright Copyright (c) 2015 - 2016, <NAME>
 * @link      https://github.com/requtize/atline
 */

namespace Requtize\Atline;

/**
 * @author<NAME> https://github.com/requtize
 */
class Environment
{
    /**
     * @var Atline\Engine
     */
    protected $engine;

    /**
     * Sets Engine object, to allow rendering other view in current.
     * 
     * @param Engine $engine
     * @return self
     */
    public function setEngine(Engine $engine)
    {
        $this->engine = $engine;

        return $this;
    }

    /**
     * Allowed filters:
     *   - safe      - Removes HTML tags and replace chars by entities: < > " '
     *   - stags     - Removes only HTML tags.
     *   - upper     - Uppercase text.
     *   - lower     - Lowercase text.
     *   - ucf       - Uppercase first letter in string.
     *
     * @param  string $filter Filter name/
     * @param  mixed  $input  Value to filtering.
     * @return mixed  Filtered value.
     */
    public function filter($filter, $input)
    {
        switch($filter)
        {
            case 'stags': $input = strip_tags($input); break;
            case 'upper': $input = mb_strtoupper($input); break;
            case 'lower': $input = mb_strtolower($input); break;
            case 'ucf':   $input = $this->fequiv_mb_ucfirst($input); break;
            case 'raw':   null; break;
            // Equivalent to = safe
            default: $input = htmlspecialchars(strip_tags($input), ENT_QUOTES);
        }<commit_msg>Fix for double HTML entities encode<commit_after><?php
/**
 * This file is part of the Atline templating system package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Copyright (c) 2015 - 2016 by <NAME>
 *
 * @license   MIT License
 * @copyright Copyright (c) 2015 - 2016, <NAME>
 * @link      https://github.com/requtize/atline
 */

namespace Requtize\Atline;

/**
 * @author<NAME> https://github.com/requtize
 */
class Environment
{
    /**
     * @var Atline\Engine
     */
    protected $engine;

    /**
     * Sets Engine object, to allow rendering other view in current.
     * 
     * @param Engine $engine
     * @return self
     */
    public function setEngine(Engine $engine)
    {
        $this->engine = $engine;

        return $this;
    }

    /**
     * Allowed filters:
     *   - safe      - Removes HTML tags and replace chars by entities: < > " '
     *   - stags     - Removes only HTML tags.
     *   - upper     - Uppercase text.
     *   - lower     - Lowercase text.
     *   - ucf       - Uppercase first letter in string.
     *
     * @param  string $filter Filter name/
     * @param  mixed  $input  Value to filtering.
     * @return mixed  Filtered value.
     */
    public function filter($filter, $input)
    {
        switch($filter)
        {
            case 'stags': $input = strip_tags($input); break;
            case 'upper': $input = mb_strtoupper($input); break;
            case 'lower': $input = mb_strtolower($input); break;
            case 'ucf':   $input = $this->fequiv_mb_ucfirst($input); break;
            case 'raw':   null; break;
            // Equivalent to = safe
            default: $input = htmlspecialchars(htmlspecialchars_decode(strip_tags($input), ENT_QUOTES), ENT_QUOTES);
        }
{'fraction_non_alphanumeric': 0.11750069118053635, 'fraction_numerical': 0.008847110865358032, 'mean_word_length': 2.06350550381033, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5294349', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1069, 'n_words': 324}