Skip to content

Commit

Permalink
Update js-cookie to v2.2.1
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Aug 27, 2019
1 parent 1df1f2d commit 0283cb6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 74 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
138 changes: 68 additions & 70 deletions 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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit 0283cb6

Please sign in to comment.