Opened 5 years ago
Closed 5 years ago
#5796 closed defect (bug) (fixed)
Viewing a post in HTML editing mode results in enetity encoded html being non-encoded
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.5 |
| Component: | TinyMCE | Version: | 2.5 |
| Severity: | normal | Keywords: | has-patch tested |
| Cc: | ffemtcj |
Description
Steps to reproduce:
- Create a new post in Visual Editor, Enter some text, Include some HTML in the Visual view (That you expect to be visible in the blog post as entity-encoded)
- Switch to HTML view, Notice that the HTML is entity encoded as expected
- Save the post (You can replace the above steps with editing a previous post with HTML in it too, as long as WordPress will default to opening in the HTML mode)
- WordPress remembers that you prefer the HTML mode, and loads up in that mode. Notice the HTML is no longer encoded
- Switch back to the Visual editor, Notice that now the previously entity-encoded HTML is being treated as inline HTML, Ie. <a href="">link</a> shown in the visual editor, will now appear as a Link.
- Saving the post now will result in the HTML being posted as HTML, rather than entity-encoded HTML
In both cases WordPress prints the code the same: (Mind you, HTML mode doesnt have the <p> tags)
<textarea class='' rows='25' cols='40' name='content' tabindex='2' id='content'><p>This is an example of HTML</p> <p>&lt;a href="Testty"&gt;Test Link&lt;/a&gt;</p> </textarea>
Attachments (2)
Change History (8)
Added a patch that does basically the same thing, plus ENT_NOQUOTES and a filter.
Note: See
TracTickets for help on using
tickets.

Not sure if htmlspecialchars() or htmlentities() should be used.
This function[htmlentities()] is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities. - http://au2.php.net/manual/en/function.htmlentities.php