Make WordPress Core


Ignore:
Timestamp:
11/21/2008 07:36:57 PM (18 years ago)
Author:
azaozz
Message:

Improve filtering of HTML entities from translated strings used in js, see #8254

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r9809 r9836  
    3131
    3232function convertEntities(o) {
    33         var p = document.createElement('p');
    34         var c = function(s) { p.innerHTML = s; return p.innerHTML; }
     33        var c = function(s) {
     34                if (/&[^;]+;/.test(s)) {
     35                        var e = document.createElement("div");
     36                        e.innerHTML = s;
     37                        return !e.firstChild ? s : e.firstChild.nodeValue;
     38                }
     39                return s;
     40        }
    3541
    36         if ( typeof o === 'object' )
     42        if ( typeof o === 'object' ) {
    3743                for (var v in o)
    3844                        o[v] = c(o[v]);
    39 
    40         else if ( typeof o === 'string' )
     45                return o;
     46        } else if ( typeof o === 'string' )
    4147                return c(o);
    42 
    43         p = null;
    4448};
    4549//]]>
Note: See TracChangeset for help on using the changeset viewer.