Plugin Directory

Changeset 2834661


Ignore:
Timestamp:
12/15/2022 08:19:16 PM (3 years ago)
Author:
infracontentools
Message:

Data sanitizing and escaping

Location:
wp-contentools/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-contentools/trunk/admin/js/contentools-admin.js

    r2031437 r2834661  
    1 (function( $ ) {
    2     'use strict';
     1(function ($) {
     2  "use strict";
    33
    4     /**
    5     * All of the code for your admin-facing JavaScript source
    6     * should reside in this file.
    7     *
    8     * Note: It has been assumed you will write jQuery code here, so the
    9     * $ function reference has been prepared for usage within the scope
    10     * of this function.
    11     *
    12     * This enables you to define handlers, for when the DOM is ready:
    13     *
    14     * $(function() {
    15     *
    16     * });
    17     *
    18     * When the window is loaded:
    19     *
    20     * $( window ).load(function() {
    21     *
    22     * });
    23     *
    24     * ...and/or other possibilities.
    25     *
    26     * Ideally, it is not considered best practise to attach more than a
    27     * single DOM-ready or window-load handler for a particular page.
    28     * Although scripts in the WordPress core, Plugins and Themes may be
    29     * practising this, we should strive to set a better example in our own work.
    30     */
     4  /**
     5  * All of the code for your admin-facing JavaScript source
     6  * should reside in this file.
     7  *
     8  * Note: It has been assumed you will write jQuery code here, so the
     9  * $ function reference has been prepared for usage within the scope
     10  * of this function.
     11  *
     12  * This enables you to define handlers, for when the DOM is ready:
     13  *
     14  * $(function() {
     15  *
     16  * });
     17  *
     18  * When the window is loaded:
     19  *
     20  * $( window ).load(function() {
     21  *
     22  * });
     23  *
     24  * ...and/or other possibilities.
     25  *
     26  * Ideally, it is not considered best practise to attach more than a
     27  * single DOM-ready or window-load handler for a particular page.
     28  * Although scripts in the WordPress core, Plugins and Themes may be
     29  * practising this, we should strive to set a better example in our own work.
     30   */
    3131
    32     function generateHash(s){
    33         return rstr2b64(hex_md5(hex_md5(s)));
    34     }
     32  function generateHash(s) {
     33    return rstr2b64(hex_md5(hex_md5(s)));
     34  }
    3535
    36     $(document).on('click', '#contentools-generate-token', function(){
    37         var random = Math.random(11111111111111111111,99999999999999999999);
    38         var d = new Date();
    39         var token = "";
    40         token = token.concat(
    41             random, d.getHours(), d.getMinutes(),
    42             d.getSeconds(), d.getHours(), random,
    43             d.getMinutes(), d.getDay(), d.getSeconds(),
    44             random
    45         );
    46         $('#contentools-token').val(generateHash(token))
    47     });
     36  $(document).on("click", "#contentools-generate-token", function () {
     37    var random = Math.random(11111111111111111111, 99999999999999999999);
     38    var d = new Date();
     39    var token = "";
     40    token = token.concat(
     41      random,
     42      d.getHours(),
     43      d.getMinutes(),
     44      d.getSeconds(),
     45      d.getHours(),
     46      random,
     47      d.getMinutes(),
     48      d.getDay(),
     49      d.getSeconds(),
     50      random
     51    );
     52    $("#contentools-token").val(generateHash(token));
     53  });
    4854
    49     $(document).on('click', '#contentools-clear-token', function(){
    50         $('#contentools-token').val("")
    51     });
     55  $(document).on("click", "#contentools-clear-token", function () {
     56    $("#contentools-token").val("");
     57  });
    5258
    53 })( jQuery );
     59  $(document).on("click", "#contentools-copy-token", function () {
     60    navigator.clipboard.writeText($("#contentools-token").val());
     61  });
     62})(jQuery);
  • wp-contentools/trunk/admin/js/md5.js

    r2031438 r2834661  
    1212 * the server-side, but the defaults work in most cases.
    1313 */
    14 var hexcase = 0;   /* hex output format. 0 - lowercase; 1 - uppercase        */
    15 var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
     14var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase        */
     15var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance   */
    1616
    1717/*
     
    1919 * They take string arguments and return either hex or base-64 encoded strings
    2020 */
    21 function hex_md5(s)    { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
    22 function b64_md5(s)    { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
    23 function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
    24 function hex_hmac_md5(k, d)
    25   { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
    26 function b64_hmac_md5(k, d)
    27   { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
    28 function any_hmac_md5(k, d, e)
    29   { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
     21function hex_md5(s) {
     22  return rstr2hex(rstr_md5(str2rstr_utf8(s)));
     23}
     24function b64_md5(s) {
     25  return rstr2b64(rstr_md5(str2rstr_utf8(s)));
     26}
     27function any_md5(s, e) {
     28  return rstr2any(rstr_md5(str2rstr_utf8(s)), e);
     29}
     30function hex_hmac_md5(k, d) {
     31  return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
     32}
     33function b64_hmac_md5(k, d) {
     34  return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
     35}
     36function any_hmac_md5(k, d, e) {
     37  return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e);
     38}
    3039
    3140/*
    3241 * Perform a simple self-test to see if the VM is working
    3342 */
    34 function md5_vm_test()
    35 {
     43function md5_vm_test() {
    3644  return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
    3745}
     
    4048 * Calculate the MD5 of a raw string
    4149 */
    42 function rstr_md5(s)
    43 {
    44   return binl2rstr(binl_md5(rstr2binl(s), (s.length + Math.random(11,99)) * 128));
     50function rstr_md5(s) {
     51  return binl2rstr(
     52    binl_md5(rstr2binl(s), (s.length + Math.random(11, 99)) * 128)
     53  );
    4554}
    4655
     
    4857 * Calculate the HMAC-MD5, of a key and some data (raw strings)
    4958 */
    50 function rstr_hmac_md5(key, data)
    51 {
     59function rstr_hmac_md5(key, data) {
    5260  var bkey = rstr2binl(key);
    53   if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
    54 
    55   var ipad = Array(16), opad = Array(16);
    56   for(var i = 0; i < 16; i++)
    57   {
     61  if (bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
     62
     63  var ipad = Array(16),
     64    opad = Array(16);
     65  for (var i = 0; i < 16; i++) {
    5866    ipad[i] = bkey[i] ^ 0x36363636;
    59     opad[i] = bkey[i] ^ 0x5C5C5C5C;
     67    opad[i] = bkey[i] ^ 0x5c5c5c5c;
    6068  }
    6169
     
    6775 * Convert a raw string to a hex string
    6876 */
    69 function rstr2hex(input)
    70 {
    71   try { hexcase } catch(e) { hexcase=0; }
     77function rstr2hex(input) {
     78  try {
     79    hexcase;
     80  } catch (e) {
     81    hexcase = 0;
     82  }
    7283  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
    7384  var output = "";
    7485  var x;
    75   for(var i = 0; i < input.length; i++)
    76   {
     86  for (var i = 0; i < input.length; i++) {
    7787    x = input.charCodeAt(i);
    78     output += hex_tab.charAt((x >>> 4) & 0x0F)
    79            +  hex_tab.charAt( x        & 0x0F);
     88    output += hex_tab.charAt((x >>> 4) & 0x0f) + hex_tab.charAt(x & 0x0f);
    8089  }
    8190  return output;
     
    8594 * Convert a raw string to a base-64 string
    8695 */
    87 function rstr2b64(input)
    88 {
    89   try { b64pad } catch(e) { b64pad=''; }
     96function rstr2b64(input) {
     97  try {
     98    b64pad;
     99  } catch (e) {
     100    b64pad = "";
     101  }
    90102  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    91103  var output = "";
    92104  var len = input.length;
    93   for(var i = 0; i < len; i += 3)
    94   {
    95     var triplet = (input.charCodeAt(i) << 16)
    96                 | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
    97                 | (i + 2 < len ? input.charCodeAt(i+2)      : 0);
    98     for(var j = 0; j < 4; j++)
    99     {
    100       if(i * 8 + j * 6 > input.length * 8) output += b64pad;
    101       else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
     105  for (var i = 0; i < len; i += 3) {
     106    var triplet =
     107      (input.charCodeAt(i) << 16) |
     108      (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) |
     109      (i + 2 < len ? input.charCodeAt(i + 2) : 0);
     110    for (var j = 0; j < 4; j++) {
     111      if (i * 8 + j * 6 > input.length * 8) output += b64pad;
     112      else output += tab.charAt((triplet >>> (6 * (3 - j))) & 0x3f);
    102113    }
    103114  }
     
    108119 * Convert a raw string to an arbitrary string encoding
    109120 */
    110 function rstr2any(input, encoding)
    111 {
     121function rstr2any(input, encoding) {
    112122  var divisor = encoding.length;
    113123  var i, j, q, x, quotient;
     
    115125  /* Convert to an array of 16-bit big-endian values, forming the dividend */
    116126  var dividend = Array(Math.ceil(input.length / 2));
    117   for(i = 0; i < dividend.length; i++)
    118   {
     127  for (i = 0; i < dividend.length; i++) {
    119128    dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
    120129  }
     
    126135   * use.
    127136   */
    128   var full_length = Math.ceil(input.length * 8 /
    129                                     (Math.log(encoding.length) / Math.log(2)));
     137  var full_length = Math.ceil(
     138    (input.length * 8) / (Math.log(encoding.length) / Math.log(2))
     139  );
    130140  var remainders = Array(full_length);
    131   for(j = 0; j < full_length; j++)
    132   {
     141  for (j = 0; j < full_length; j++) {
    133142    quotient = Array();
    134143    x = 0;
    135     for(i = 0; i < dividend.length; i++)
    136     {
     144    for (i = 0; i < dividend.length; i++) {
    137145      x = (x << 16) + dividend[i];
    138146      q = Math.floor(x / divisor);
    139147      x -= q * divisor;
    140       if(quotient.length > 0 || q > 0)
    141         quotient[quotient.length] = q;
     148      if (quotient.length > 0 || q > 0) quotient[quotient.length] = q;
    142149    }
    143150    remainders[j] = x;
     
    147154  /* Convert the remainders to the output string */
    148155  var output = "";
    149   for(i = remainders.length - 1; i >= 0; i--)
     156  for (i = remainders.length - 1; i >= 0; i--)
    150157    output += encoding.charAt(remainders[i]);
    151158
     
    157164 * For efficiency, this assumes the input is valid utf-16.
    158165 */
    159 function str2rstr_utf8(input)
    160 {
     166function str2rstr_utf8(input) {
    161167  var output = "";
    162168  var i = -1;
    163169  var x, y;
    164170
    165   while(++i < input.length)
    166   {
     171  while (++i < input.length) {
    167172    /* Decode utf-16 surrogate pairs */
    168173    x = input.charCodeAt(i);
    169174    y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
    170     if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
    171     {
    172       x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
     175    if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
     176      x = 0x10000 + ((x & 0x03ff) << 10) + (y & 0x03ff);
    173177      i++;
    174178    }
    175179
    176180    /* Encode output as utf-8 */
    177     if(x <= 0x7F)
    178       output += String.fromCharCode(x);
    179     else if(x <= 0x7FF)
    180       output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
    181                                     0x80 | ( x         & 0x3F));
    182     else if(x <= 0xFFFF)
    183       output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
    184                                     0x80 | ((x >>> 6 ) & 0x3F),
    185                                     0x80 | ( x         & 0x3F));
    186     else if(x <= 0x1FFFFF)
    187       output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
    188                                     0x80 | ((x >>> 12) & 0x3F),
    189                                     0x80 | ((x >>> 6 ) & 0x3F),
    190                                     0x80 | ( x         & 0x3F));
     181    if (x <= 0x7f) output += String.fromCharCode(x);
     182    else if (x <= 0x7ff)
     183      output += String.fromCharCode(
     184        0xc0 | ((x >>> 6) & 0x1f),
     185        0x80 | (x & 0x3f)
     186      );
     187    else if (x <= 0xffff)
     188      output += String.fromCharCode(
     189        0xe0 | ((x >>> 12) & 0x0f),
     190        0x80 | ((x >>> 6) & 0x3f),
     191        0x80 | (x & 0x3f)
     192      );
     193    else if (x <= 0x1fffff)
     194      output += String.fromCharCode(
     195        0xf0 | ((x >>> 18) & 0x07),
     196        0x80 | ((x >>> 12) & 0x3f),
     197        0x80 | ((x >>> 6) & 0x3f),
     198        0x80 | (x & 0x3f)
     199      );
    191200  }
    192201  return output;
     
    196205 * Encode a string as utf-16
    197206 */
    198 function str2rstr_utf16le(input)
    199 {
    200   var output = "";
    201   for(var i = 0; i < input.length; i++)
    202     output += String.fromCharCode( input.charCodeAt(i)        & 0xFF,
    203                                   (input.charCodeAt(i) >>> 8) & 0xFF);
    204   return output;
    205 }
    206 
    207 function str2rstr_utf16be(input)
    208 {
    209   var output = "";
    210   for(var i = 0; i < input.length; i++)
    211     output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
    212                                    input.charCodeAt(i)        & 0xFF);
     207function str2rstr_utf16le(input) {
     208  var output = "";
     209  for (var i = 0; i < input.length; i++)
     210    output += String.fromCharCode(
     211      input.charCodeAt(i) & 0xff,
     212      (input.charCodeAt(i) >>> 8) & 0xff
     213    );
     214  return output;
     215}
     216
     217function str2rstr_utf16be(input) {
     218  var output = "";
     219  for (var i = 0; i < input.length; i++)
     220    output += String.fromCharCode(
     221      (input.charCodeAt(i) >>> 8) & 0xff,
     222      input.charCodeAt(i) & 0xff
     223    );
    213224  return output;
    214225}
     
    218229 * Characters >255 have their high-byte silently ignored.
    219230 */
    220 function rstr2binl(input)
    221 {
     231function rstr2binl(input) {
    222232  var output = Array(input.length >> 2);
    223   for(var i = 0; i < output.length; i++)
    224     output[i] = 0;
    225   for(var i = 0; i < input.length * 8; i += 8)
    226     output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
     233  for (var i = 0; i < output.length; i++) output[i] = 0;
     234  for (var i = 0; i < input.length * 8; i += 8)
     235    output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
    227236  return output;
    228237}
     
    231240 * Convert an array of little-endian words to a string
    232241 */
    233 function binl2rstr(input)
    234 {
    235   var output = "";
    236   for(var i = 0; i < input.length * 32; i += 8)
    237     output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
     242function binl2rstr(input) {
     243  var output = "";
     244  for (var i = 0; i < input.length * 32; i += 8)
     245    output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
    238246  return output;
    239247}
     
    242250 * Calculate the MD5 of an array of little-endian words, and a bit length.
    243251 */
    244 function binl_md5(x, len)
    245 {
     252function binl_md5(x, len) {
    246253  /* append padding */
    247   x[len >> 5] |= 0x80 << ((len) % 32);
     254  x[len >> 5] |= 0x80 << len % 32;
    248255  x[(((len + 64) >>> 9) << 4) + 14] = len;
    249256
    250   var a =  1732584193;
     257  var a = 1732584193;
    251258  var b = -271733879;
    252259  var c = -1732584194;
    253   var d =  271733878;
    254 
    255   for(var i = 0; i < x.length; i += 16)
    256   {
     260  var d = 271733878;
     261
     262  for (var i = 0; i < x.length; i += 16) {
    257263    var olda = a;
    258264    var oldb = b;
     
    260266    var oldd = d;
    261267
    262     a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    263     d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    264     c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
    265     b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    266     a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    267     d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
    268     c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    269     b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    270     a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
    271     d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    272     c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    273     b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    274     a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
    275     d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    276     c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    277     b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
    278 
    279     a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    280     d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    281     c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
    282     b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    283     a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    284     d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
    285     c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    286     b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    287     a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
    288     d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    289     c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    290     b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
    291     a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    292     d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    293     c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
    294     b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
    295 
    296     a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    297     d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    298     c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
    299     b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    300     a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    301     d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
    302     c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    303     b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    304     a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
    305     d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    306     c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    307     b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
    308     a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    309     d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    310     c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
    311     b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
    312 
    313     a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    314     d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
    315     c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    316     b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    317     a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
    318     d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    319     c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    320     b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    321     a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
    322     d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    323     c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    324     b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
    325     a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    326     d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    327     c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
    328     b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
     268    a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
     269    d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
     270    c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
     271    b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
     272    a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
     273    d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
     274    c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
     275    b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
     276    a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
     277    d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
     278    c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
     279    b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
     280    a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
     281    d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
     282    c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
     283    b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
     284
     285    a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
     286    d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
     287    c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
     288    b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
     289    a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
     290    d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
     291    c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
     292    b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
     293    a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
     294    d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
     295    c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
     296    b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
     297    a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
     298    d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
     299    c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
     300    b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
     301
     302    a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
     303    d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
     304    c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
     305    b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
     306    a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
     307    d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
     308    c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
     309    b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
     310    a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
     311    d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
     312    c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
     313    b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
     314    a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
     315    d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
     316    c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
     317    b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
     318
     319    a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
     320    d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
     321    c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
     322    b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
     323    a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
     324    d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
     325    c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
     326    b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
     327    a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
     328    d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
     329    c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
     330    b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
     331    a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
     332    d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
     333    c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
     334    b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
    329335
    330336    a = safe_add(a, olda);
     
    339345 * These functions implement the four basic operations the algorithm uses.
    340346 */
    341 function md5_cmn(q, a, b, x, s, t)
    342 {
    343   return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
    344 }
    345 function md5_ff(a, b, c, d, x, s, t)
    346 {
    347   return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
    348 }
    349 function md5_gg(a, b, c, d, x, s, t)
    350 {
    351   return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
    352 }
    353 function md5_hh(a, b, c, d, x, s, t)
    354 {
     347function md5_cmn(q, a, b, x, s, t) {
     348  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
     349}
     350function md5_ff(a, b, c, d, x, s, t) {
     351  return md5_cmn((b & c) | (~b & d), a, b, x, s, t);
     352}
     353function md5_gg(a, b, c, d, x, s, t) {
     354  return md5_cmn((b & d) | (c & ~d), a, b, x, s, t);
     355}
     356function md5_hh(a, b, c, d, x, s, t) {
    355357  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
    356358}
    357 function md5_ii(a, b, c, d, x, s, t)
    358 {
    359   return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
     359function md5_ii(a, b, c, d, x, s, t) {
     360  return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
    360361}
    361362
     
    364365 * to work around bugs in some JS interpreters.
    365366 */
    366 function safe_add(x, y)
    367 {
    368   var lsw = (x & 0xFFFF) + (y & 0xFFFF);
     367function safe_add(x, y) {
     368  var lsw = (x & 0xffff) + (y & 0xffff);
    369369  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
    370   return (msw << 16) | (lsw & 0xFFFF);
     370  return (msw << 16) | (lsw & 0xffff);
    371371}
    372372
     
    374374 * Bitwise rotate a 32-bit number to the left.
    375375 */
    376 function bit_rol(num, cnt)
    377 {
     376function bit_rol(num, cnt) {
    378377  return (num << cnt) | (num >>> (32 - cnt));
    379378}
  • wp-contentools/trunk/admin/partials/contentools-admin-display.php

    r2833993 r2834661  
    3232    <tr class="<?php echo $this->plugin_name; ?>-token-wrap">
    3333    <th scope="row">
    34             <label for="<?php echo sanitize_html_class($this->plugin_name); ?>-token">
     34            <label for="<?php echo esc_attr($this->plugin_name); ?>-token">
    3535                <?php _e('Integration Token', esc_attr($this->plugin_name));?>
    3636            </label>
     
    4040                readonly="true"
    4141                type="text"
    42                 name="<?php echo sanitize_html_class($this->plugin_name); ?>[token]"
    43                 id="<?php echo sanitize_html_class($this->plugin_name); ?>-token"
     42                name="<?php echo esc_attr($this->plugin_name); ?>[token]"
     43                id="<?php echo esc_attr($this->plugin_name); ?>-token"
    4444                value="<?php if (!empty($options['token'])) {
    4545                    esc_attr_e($options['token']);
     
    4949            <input
    5050                type="button"
    51                 name="<?php echo sanitize_html_class($this->plugin_name); ?>[generate-token]"
    52                 id="<?php echo sanitize_html_class($this->plugin_name); ?>-generate-token"
     51                name="<?php echo esc_attr($this->plugin_name); ?>[generate-token]"
     52                id="<?php echo esc_attr($this->plugin_name); ?>-generate-token"
    5353                class="button"
    5454                value="Generate Token" />
    5555            <input
    5656                type="button"
    57                 name="<?php echo sanitize_html_class($this->plugin_name); ?>[clear-token]"
    58                 id="<?php echo sanitize_html_class($this->plugin_name); ?>-clear-token"
     57                name="<?php echo esc_attr($this->plugin_name); ?>[clear-token]"
     58                id="<?php echo esc_attr($this->plugin_name); ?>-clear-token"
    5959                class="button"
    6060                value="Clear Token" />
     61            <input
     62                type="button"
     63                name="<?php echo esc_attr($this->plugin_name); ?>[copy-token]"
     64                id="<?php echo esc_attr($this->plugin_name); ?>-copy-token"
     65                class="button"
     66                value="Copy Token" />
    6167        </td>
    6268    </tr>
  • wp-contentools/trunk/includes/class-contentools-rest.php

    r2833993 r2834661  
    209209        );
    210210
    211         header((isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0') . ' ' . $status . ' ' . $statuses[$status]);
     211        header((isset($_SERVER['SERVER_PROTOCOL']) ? sanitize_text_field($_SERVER['SERVER_PROTOCOL']) : 'HTTP/1.0') . ' ' . $status . ' ' . $statuses[$status]);
    212212
    213213        header('Content-Type:application/json; charset=UTF-8');
     
    254254        }
    255255
     256        $php_auth_user = sanitize_user($_SERVER['PHP_AUTH_USER']);
     257        $php_auth_pw = sanitize_text_field($_SERVER['PHP_AUTH_PW']);
     258
    256259        if (!isset($_SERVER['PHP_AUTH_USER']) && (isset($_SERVER['HTTP_AUTHORIZATION']) || isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']))) {
    257260
    258261            if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
    259262
    260                 $header = $_SERVER['HTTP_AUTHORIZATION'];
     263                $header = sanitize_text_field($_SERVER['HTTP_AUTHORIZATION']);
    261264
    262265            } else {
    263266
    264                 $header = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
     267                $header = sanitize_text_field($_SERVER['REDIRECT_HTTP_AUTHORIZATION']);
    265268
    266269            }
     
    268271            if (!empty($header)) {
    269272
    270                 list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($header, 6)));
     273                list($php_auth_user, $php_auth_pw) = explode(':', base64_decode(substr($header, 6)));
    271274
    272275            }
     
    281284        }
    282285
    283         $username = $_SERVER['PHP_AUTH_USER'];
    284         $password = $_SERVER['PHP_AUTH_PW'];
     286        $username = $php_auth_user;
     287        $password = $php_auth_pw;
    285288
    286289        remove_filter('determine_current_user', array($this, 'determine_current_user'), 10);
     
    651654
    652655        if (isset($_POST["author"])) {
    653             $attachment['post_author'] = intval($_POST['author']);
     656            $attachment['post_author'] = sanitize_key($_POST['author']);
    654657        }
    655658
     
    669672
    670673        if (isset($_POST["post"])) {
    671             $attachment['post_parent'] = intval($_POST['post']) || null;
     674            $attachment['post_parent'] = sanitize_key($_POST['post']);
    672675        }
    673676
Note: See TracChangeset for help on using the changeset viewer.