Contao: encode / decode problem with text area

Created on 6 Sep 2019  路  3Comments  路  Source: contao/contao

Versions
all

https://github.com/contao/contao/blob/326bbb6b42bf9723edc598c035f125c7fe6ae84c/core-bundle/src/Resources/contao/forms/FormTextArea.php#L144

Description
Textarea form widgets encodes "<" on first submission but double decodes it on second submission.
In the end, the widgets should not encode anything on their own but I know this is not to be changed before Contao 5 for bc sake.
However, I think the double encoding (see reproduction below) should be adressed.

How to reproduce

  1. add a new form (disable HTML validation!)
  2. add a text area to it.
  3. add any mandatory field
  4. open form in frontend
  5. Type open: <, close: >, ampersand: & into the textarea but leave the mandatory field empty.
  6. submit the form
  7. The content of the text area has changed to: open: &lt;, close: >, ampersand: &
  8. submit the form again
  9. the content of the text area is now open: <, close: >, ampersand: & again.
  10. start again at 6. :smile_cat: to do the endless loop

thx at @discordier to check this

bug

All 3 comments

The problem is the double encoding in the FormTextArea class, which we have introduced in contao/core#8623 (see @ausi's comment). @ausi Maybe we have to rethink the solution?

As discussed in Mumble on May 7th, we want to revert the changes from contao/core#8623 and add a case 'valueRaw' instead. This should fix both issues.

Also, we want to add a comment so we do not forget to remove the specialchars() in Contao 5.

@sebj54 Regarding your ticket contao/core#8623: You can use $textAreaWidget->rawValue to retrieve the unescaped value once #1714 has been merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aschempp picture aschempp  路  3Comments

Alibi-Contao picture Alibi-Contao  路  3Comments

leofeyer picture leofeyer  路  3Comments

rabauss picture rabauss  路  3Comments

issue-bot picture issue-bot  路  4Comments