Skip to content

[BUG] Inconsistent behavior of Phalcon\Tag::setAutoescape() #1263

Closed
@ghost

Description

\Phalcon\Tag::setAutoescape(false);
echo \Phalcon\Tag::textField(array('name', 'value' => '&"')), PHP_EOL;

\Phalcon\Tag::setAutoescape(true);
echo \Phalcon\Tag::textField(array('name', 'value' => '&"')), PHP_EOL;

\Phalcon\Tag::setDefault('name', '&"');

\Phalcon\Tag::setAutoescape(false);
echo \Phalcon\Tag::textField(array('name')), PHP_EOL;

\Phalcon\Tag::setAutoescape(true);
echo \Phalcon\Tag::textField(array('name')), PHP_EOL;

produces

<input type="text" value="&amp;&quot;" name="name" id="name" />
<input type="text" value="&amp;&quot;" name="name" id="name" />
<input type="text" name="name" id="name" value="&amp;&quot;" />
<input type="text" name="name" id="name" value="&amp;#x26;&amp;#x22;" />

value is escaped due to the bug introduced in a462ba2

However, the real issue is that Phalcon\Tag::getValue() only escapes the value when it is set either by setDefault() or is present in $_POST; if the value was specified in $params array it is NOT escaped by getValue() regardless of _autoEscape.

In the second case I would expect to see

<input type="text" value="&amp;amp;&amp;quot;" name="name" id="name" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions