[wp-trac] [WordPress Trac] #28727: plugin editor content empty when source contains an invalid character
WordPress Trac
noreply at wordpress.org
Thu Jul 3 11:39:45 UTC 2014
#28727: plugin editor content empty when source contains an invalid character
----------------------------+-----------------------------
Reporter: bobbingwide | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 3.9.1
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
I happened to create a plugin source file which contained a pound sterling
character (£) copied and pasted from a web page, and which therefore
appeared in my Windows text editor as lower case u acute ( hex A3, ascii
163 ).
esc_textarea() makes a call to htmlspecialchars() which returns a null
value for safe text.
{{{
$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option(
'blog_charset' ) );
}}}
Note: blog_charset is UTF-8
So the plugin editor displayed nothing at all for the source.
Question: Is this really the expected behaviour?
The documentation for htmlspecialchars says
If the input string contains an invalid code unit sequence within the
given encoding an empty string will be returned, unless either the
ENT_IGNORE or ENT_SUBSTITUTE flags are set.
Shouldn't the plugin editor pass ENT_IGNORE OR otherwise issue a message
to the user at least advising not to save the empty file when the safe
content is nothing like the original.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28727>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list