Opened 9 years ago
Last modified 6 years ago
#33466 assigned defect (bug)
wpautop breaks multi-line textarea content
Reported by: | takayukister | Owned by: | miqrogroove |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | wpautop |
Focuses: | Cc: |
Description (last modified by )
Applying wpautop() breaks multi-line content of textarea element because it replaces each newline with <br />
. A textarea can't have HTML in its content.
You can reproduce the problem with the following code:
$text = '<textarea name="test"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</textarea>'; echo wpautop( $text );
Attachments (4)
Change History (16)
#1
@
9 years ago
- Keywords needs-patch dev-feedback added
- Version changed from trunk to 4.3
I strongly suspect this is related to #33377.
#2
@
9 years ago
- Keywords needs-refresh added; needs-patch removed
Patch needs refresh to apply from correct directory, not a new patch. Working on it now.
#3
@
9 years ago
- Keywords has-patch added; needs-refresh removed
- Milestone changed from Awaiting Review to 4.4
- Owner set to chriscct7
- Status changed from new to assigned
New patch from proper directory. Ready for merge post @azaozz or @miqrogroove review. Could be a 4.3.1 candidate.
#5
@
9 years ago
- Keywords needs-unit-tests added
I think we need to take a very thoughtful look at why we are treating PRE differently from SCRIPT and STYLE. Until we have that sorted out, I'm not confident we have the best patch here. Anyone have thoughts on that already?
#6
@
9 years ago
- Description modified (diff)
- Keywords dev-feedback has-patch needs-unit-tests removed
- Version 4.3 deleted
4.3 and 4.2 both failed the attached tests. I am correcting the ticket, including the description to reflect the fact that a newline is required after any textarea element. Omitting the newline causes browsers to strip leading whitespace.
#7
@
9 years ago
The four tags that need "special treatment" are pre
, scritp
, style
and textarea
. We want to preserve line breaks/white space in them and prevent any extra tags like <br>
. This needs to happen in both wpautop -- JS and PHP.
In addition:
- For
<pre>
we need to keep consecutive white spaces. - For
<textarea>
we may have to make sure</textarea>
is escaped to</textarea>
(needs testing).
The above patches are a good start but thinking we can handle these four tags in the same way as suggested in comment 5. This needs to be in both JS and PHP.
patch for wpautop