[wp-trac] [WordPress Trac] #26307: Link tool in basic editor should escape quotes

WordPress Trac noreply at wordpress.org
Wed Jan 15 19:49:32 UTC 2014


#26307: Link tool in basic editor should escape quotes
--------------------------+--------------------
 Reporter:  krinklemail   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.9
Component:  Editor        |     Version:  3.7.1
 Severity:  major         |  Resolution:
 Keywords:  has-patch     |
--------------------------+--------------------

Comment (by JanHenkG):

 A good function to escape HTML in Javascript is the following function:


 {{{
 function escapeHtml(text) {
     return text
         .replace(/&/g, "&")
         .replace(/</g, "<")
         .replace(/>/g, ">")
         .replace(/"/g, """)
         .replace(/'/g, "'");
 }
 }}}

 The easiest fix is to just inline this function and only apply it to the
 title attribute of the link being build. But I can imagine that the
 functionality for escaping HTML could be reused elsewhere in the future,
 so maybe there is a better location to put this function? Maybe as a
 function in the {{{ wp-includes/js/utils.js}}} file? Or maybe in a new
 Javascript file, for example {{{ wp-includes/js/formatting.js }}}?

 I am new to WordPress contributing, so if someone could tell me what would
 be the best approach in line with the WordPress coding standards, I am
 happy to implement it and provide a patch.

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


More information about the wp-trac mailing list