[wp-trac] [WordPress Trac] #50551: Add esc_xml l10n helpers

WordPress Trac noreply at wordpress.org
Thu Oct 15 16:34:23 UTC 2020


#50551: Add esc_xml l10n helpers
-------------------------------------+------------------------------
 Reporter:  swissspidy               |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  I18N                     |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:
-------------------------------------+------------------------------
Changes (by helen):

 * milestone:  5.6 => Awaiting Review


Comment:

 Thinking about this more holistically, I don't see consistency as an end
 goal to have, and I want us to think about what `esc_xml()` communicates
 to developers in terms of its intended and/or proper usage. We have an
 existing problem in `esc_html()` vs. `esc_js()`, where the former means
 "escape any HTML in here" and the latter means "escape for (a very narrow
 subset of) JavaScript usage". This feels more like the `esc_js()` case,
 and that's not a good thing because I see that function misused
 constantly. Even the docblock for `esc_xml()` is vague: `Escaping for XML
 blocks.`. The filter contained within does a better job: `Filters a string
 cleaned and escaped for output in XML.` Functionally maybe this means the
 same thing, but the intention is different IMO and may mean that the
 function actually has a greater scope of escaping.

 If we add translation functions, what does that communicate to developers?
 Is there general understanding that they are "just" wrappers to avoid a
 couple parens or does it end up saying "you **should** be translating
 fully formed XML"? The latter sounds ridiculous and I hope that wouldn't
 be the takeaway, but generally when adding functions I want to be more
 thoughtful about what it's telling developers is good practice and that's
 something I can see happening.

 In any case, we can discuss further, for now I'm punting out of 5.6 at
 least and leaving it to @ocean90 et al about a `maybelater` status.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50551#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list