WordPress.org

Make WordPress Core

Ticket #4502: 4502.diff

File 4502.diff, 2.3 KB (added by Nazgul, 11 years ago)
  • wp-includes/js/prototype.js

     
    1 /*  Prototype JavaScript framework, version 1.5.1
     1/*  Prototype JavaScript framework, version 1.5.1.1
    22 *  (c) 2005-2007 Sam Stephenson
    33 *
    44 *  Prototype is freely distributable under the terms of an MIT-style license.
     
    77/*--------------------------------------------------------------------------*/
    88
    99var Prototype = {
    10   Version: '1.5.1',
     10  Version: '1.5.1.1',
    1111
    1212  Browser: {
    1313    IE:     !!(window.attachEvent && !window.opera),
     
    2424       document.createElement('form').__proto__)
    2525  },
    2626
    27   ScriptFragment: '<script[^>]*>([\\s\\S]*?)<\/script>',
    28   JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
     27  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
     28  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
    2929
    3030  emptyFunction: function() { },
    3131  K: function(x) { return x }
     
    364364    return this.sub(filter || Prototype.JSONFilter, '#{1}');
    365365  },
    366366
     367  isJSON: function() {
     368    var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
     369    return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
     370  },
     371
    367372  evalJSON: function(sanitize) {
    368373    var json = this.unfilterJSON();
    369374    try {
    370       if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json)))
    371         return eval('(' + json + ')');
     375      if (!sanitize || json.isJSON()) return eval('(' + json + ')');
    372376    } catch (e) { }
    373377    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
    374378  },
     
    12701274
    12711275} else document.getElementsByClassName = function(className, parentElement) {
    12721276  var children = ($(parentElement) || document.body).getElementsByTagName('*');
    1273   var elements = [], child;
     1277  var elements = [], child, pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
    12741278  for (var i = 0, length = children.length; i < length; i++) {
    12751279    child = children[i];
    1276     if (Element.hasClassName(child, className))
     1280    var elementClassName = child.className;
     1281    if (elementClassName.length == 0) continue;
     1282    if (elementClassName == className || elementClassName.match(pattern))
    12771283      elements.push(Element.extend(child));
    12781284  }
    12791285  return elements;