Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode / decode problem with text area #736

Closed
zonky2 opened this issue Sep 6, 2019 · 3 comments · Fixed by #1714
Closed

encode / decode problem with text area #736

zonky2 opened this issue Sep 6, 2019 · 3 comments · Fixed by #1714
Assignees
Labels
Milestone

Comments

@zonky2
Copy link
Contributor

zonky2 commented Sep 6, 2019

Versions
all

return StringUtil::specialchars(str_replace('\n', "\n", $this->varValue), false, true);

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. 😸 to do the endless loop

thx at @discordier to check this

@leofeyer
Copy link
Member

leofeyer commented May 4, 2020

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?

@leofeyer leofeyer added the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label May 4, 2020
@leofeyer
Copy link
Member

leofeyer commented May 7, 2020

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.

@leofeyer leofeyer removed the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label May 7, 2020
@leofeyer leofeyer self-assigned this May 8, 2020
@leofeyer leofeyer linked a pull request May 8, 2020 that will close this issue
@leofeyer leofeyer closed this as completed May 8, 2020
@leofeyer
Copy link
Member

leofeyer commented May 8, 2020

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

leofeyer added a commit that referenced this issue May 8, 2020
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes #736
| Docs PR or issue | -

<!--
Bugfixes should be based on the 4.4 or 4.9 branch and features on the master
branch. Select the correct branch in the "base:" drop-down menu above.

Replace this notice with a short README for your feature/bugfix. This will help
people to understand your PR and can be used as a start for the documentation.
-->

Commits
-------

5eca151 Add a "rawValue" property to the TextArea class
69e5870 Also remove the str_replace() when returning the raw value
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants