From 0283cb6f72125ecc875357a06e6bfe86d28225a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 27 Aug 2019 14:47:06 -0300 Subject: [PATCH] Update js-cookie to v2.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- ChangeLog | 1 + js/vendor/js.cookie.js | 138 ++++++++++++++++++++--------------------- package.json | 2 +- yarn.lock | 7 ++- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91e3969d7624..2c82e8901bdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ phpMyAdmin - ChangeLog - issue Update jQuery Migrate to v3.1.0 - issue Update jQuery Validation to v1.19.1 - issue Update jQuery to v3.4.1 +- issue Update js-cookie to v2.2.1 4.9.0.1 (2019-06-04) - issue #14478 phpMyAdmin no longer streams the export data diff --git a/js/vendor/js.cookie.js b/js/vendor/js.cookie.js index 9a0945ed89c6..80a755124a41 100644 --- a/js/vendor/js.cookie.js +++ b/js/vendor/js.cookie.js @@ -1,12 +1,12 @@ /*! - * JavaScript Cookie v2.2.0 + * JavaScript Cookie v2.2.1 * https://github.com/js-cookie/js-cookie * * Copyright 2006, 2015 Klaus Hartl & Fagner Brack * Released under the MIT license */ ;(function (factory) { - var registeredInModuleLoader = false; + var registeredInModuleLoader; if (typeof define === 'function' && define.amd) { define(factory); registeredInModuleLoader = true; @@ -36,126 +36,124 @@ return result; } + function decode (s) { + return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent); + } + function init (converter) { - function api (key, value, attributes) { - var result; + function api() {} + + function set (key, value, attributes) { if (typeof document === 'undefined') { return; } - // Write - - if (arguments.length > 1) { - attributes = extend({ - path: '/' - }, api.defaults, attributes); - - if (typeof attributes.expires === 'number') { - var expires = new Date(); - expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); - attributes.expires = expires; - } + attributes = extend({ + path: '/' + }, api.defaults, attributes); - // We're using "expires" because "max-age" is not supported by IE - attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; + if (typeof attributes.expires === 'number') { + attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5); + } - try { - result = JSON.stringify(value); - if (/^[\{\[]/.test(result)) { - value = result; - } - } catch (e) {} + // We're using "expires" because "max-age" is not supported by IE + attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; - if (!converter.write) { - value = encodeURIComponent(String(value)) - .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); - } else { - value = converter.write(value, key); + try { + var result = JSON.stringify(value); + if (/^[\{\[]/.test(result)) { + value = result; } + } catch (e) {} - key = encodeURIComponent(String(key)); - key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); - key = key.replace(/[\(\)]/g, escape); + value = converter.write ? + converter.write(value, key) : + encodeURIComponent(String(value)) + .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); - var stringifiedAttributes = ''; + key = encodeURIComponent(String(key)) + .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent) + .replace(/[\(\)]/g, escape); - for (var attributeName in attributes) { - if (!attributes[attributeName]) { - continue; - } - stringifiedAttributes += '; ' + attributeName; - if (attributes[attributeName] === true) { - continue; - } - stringifiedAttributes += '=' + attributes[attributeName]; + var stringifiedAttributes = ''; + for (var attributeName in attributes) { + if (!attributes[attributeName]) { + continue; } - return (document.cookie = key + '=' + value + stringifiedAttributes); + stringifiedAttributes += '; ' + attributeName; + if (attributes[attributeName] === true) { + continue; + } + + // Considers RFC 6265 section 5.2: + // ... + // 3. If the remaining unparsed-attributes contains a %x3B (";") + // character: + // Consume the characters of the unparsed-attributes up to, + // not including, the first %x3B (";") character. + // ... + stringifiedAttributes += '=' + attributes[attributeName].split(';')[0]; } - // Read + return (document.cookie = key + '=' + value + stringifiedAttributes); + } - if (!key) { - result = {}; + function get (key, json) { + if (typeof document === 'undefined') { + return; } + var jar = {}; // To prevent the for loop in the first place assign an empty array - // in case there are no cookies at all. Also prevents odd result when - // calling "get()" + // in case there are no cookies at all. var cookies = document.cookie ? document.cookie.split('; ') : []; - var rdecode = /(%[0-9A-Z]{2})+/g; var i = 0; for (; i < cookies.length; i++) { var parts = cookies[i].split('='); var cookie = parts.slice(1).join('='); - if (!this.json && cookie.charAt(0) === '"') { + if (!json && cookie.charAt(0) === '"') { cookie = cookie.slice(1, -1); } try { - var name = parts[0].replace(rdecode, decodeURIComponent); - cookie = converter.read ? - converter.read(cookie, name) : converter(cookie, name) || - cookie.replace(rdecode, decodeURIComponent); + var name = decode(parts[0]); + cookie = (converter.read || converter)(cookie, name) || + decode(cookie); - if (this.json) { + if (json) { try { cookie = JSON.parse(cookie); } catch (e) {} } + jar[name] = cookie; + if (key === name) { - result = cookie; break; } - - if (!key) { - result[name] = cookie; - } } catch (e) {} } - return result; + return key ? jar[key] : jar; } - api.set = api; + api.set = set; api.get = function (key) { - return api.call(api, key); + return get(key, false /* read as raw */); }; - api.getJSON = function () { - return api.apply({ - json: true - }, [].slice.call(arguments)); + api.getJSON = function (key) { + return get(key, true /* read as json */); }; - api.defaults = {}; - api.remove = function (key, attributes) { - api(key, '', extend(attributes, { + set(key, '', extend(attributes, { expires: -1 })); }; + api.defaults = {}; + api.withConverter = init; return api; diff --git a/package.json b/package.json index fa8ba4cdd581..b627be04ef2e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "jquery-ui-timepicker-addon": "1.6.3", "jquery-validation": "1.19.1", "jquery.event.drag": "2.2.2", - "js-cookie": "2.2.0", + "js-cookie": "2.2.1", "tracekit": "0.4.5", "updated-jqplot": "1.0.9", "zxcvbn": "4.4.2" diff --git a/yarn.lock b/yarn.lock index 6a49210643ce..c1e322ac1ea4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -494,9 +494,10 @@ jquery@3.4.1: resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== -js-cookie@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.0.tgz#1b2c279a6eece380a12168b92485265b35b1effb" +js-cookie@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" + integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ== js-tokens@^3.0.2: version "3.0.2"