This patch should do the trick. It updates the cookie plugin to 1.4.0 and sets the binary package version to 1:1.4.0, which insures us that the package manager will upgrade to this version on all systems which have version <= 8-2 installed.
-- Jerome --- cookie/CHANGELOG.md | 65 ++++++++++++++++ cookie/CONTRIBUTING.md | 53 +++++++++++++ cookie/MIT-LICENSE.txt | 20 +++++ cookie/README | 0 cookie/README.md | 146 +++++++++++++++++++++++++++++++++++ cookie/jquery.cookie.js | 198 +++++++++++++++++++++++++++--------------------- cookie/server.js | 24 ------ cookie/test.html | 19 ----- cookie/test.js | 65 ---------------- debian/copyright | 3 +- debian/rules | 5 ++ 11 files changed, 403 insertions(+), 195 deletions(-) create mode 100644 cookie/CHANGELOG.md create mode 100644 cookie/CONTRIBUTING.md create mode 100644 cookie/MIT-LICENSE.txt delete mode 100644 cookie/README create mode 100644 cookie/README.md delete mode 100644 cookie/server.js delete mode 100644 cookie/test.html delete mode 100644 cookie/test.js diff --git a/cookie/CHANGELOG.md b/cookie/CHANGELOG.md new file mode 100644 index 0000000..467dd42 --- /dev/null +++ b/cookie/CHANGELOG.md @@ -0,0 +1,65 @@ +HEAD +----- + +1.4.0 +----- +- Support for AMD. + +- Removed deprecated method `$.cookie('name', null)` for deleting a cookie, + use `$.removeCookie('name')`. + +- `$.cookie('name')` now returns `undefined` in case such cookie does not exist + (was `null`). Because the return value is still falsy, testing for existence + of a cookie like `if ( $.cookie('foo') )` keeps working without change. + +- Renamed bower package definition (component.json -> bower.json) for usage + with up-to-date bower. + +- Badly encoded cookies no longer throw exception upon reading but do return + undefined (similar to how we handle JSON parse errors with json = true). + +- Added conversion function as optional last argument for reading, + so that values can be changed to a different representation easily on the fly. + Useful for parsing numbers for instance: + + ```javascript + $.cookie('foo', '42'); + $.cookie('foo', Number); // => 42 + ``` + +1.3.1 +----- +- Fixed issue where it was no longer possible to check for an arbitrary cookie, + while json is set to true, there was a SyntaxError thrown from JSON.parse. + +- Fixed issue where RFC 2068 decoded cookies were not properly read. + +1.3.0 +----- +- Configuration options: `raw`, `json`. Replaces raw option, becomes config: + + ```javascript + $.cookie.raw = true; // bypass encoding/decoding the cookie value + $.cookie.json = true; // automatically JSON stringify/parse value + ``` + + Thus the default options now cleanly contain cookie attributes only. + +- Removing licensing under GPL Version 2, the plugin is now released under MIT License only +(keeping it simple and following the jQuery library itself here). + +- Bugfix: Properly handle RFC 2068 quoted cookie values. + +- Added component.json for bower. + +- Added jQuery plugin package manifest. + +- `$.cookie()` returns all available cookies. + +1.2.0 +----- +- Adding `$.removeCookie('foo')` for deleting a cookie, using `$.cookie('foo', null)` is now deprecated. + +1.1 +--- +- Adding default options. diff --git a/cookie/CONTRIBUTING.md b/cookie/CONTRIBUTING.md new file mode 100644 index 0000000..f174678 --- /dev/null +++ b/cookie/CONTRIBUTING.md @@ -0,0 +1,53 @@ +##Issues + +- Report issues or feature requests on [GitHub Issues](https://github.com/carhartl/jquery-cookie/issues). +- If reporting a bug, please add a [simplified example](http://sscce.org/). + +##Pull requests +- Create a new topic branch for every separate change you make. +- Create a test case if you are fixing a bug or implementing an important feature. +- Make sure the build runs successfully. + +## Development + +###Tools +We use the following tools for development: + +- [Qunit](http://qunitjs.com/) for tests. +- [NodeJS](http://nodejs.org/download/) required to run grunt and the test server only. +- [Grunt](http://gruntjs.com/getting-started) for task management. + +###Getting started +Install [NodeJS](http://nodejs.org/). +Install globally grunt-cli using the following command: + + $ npm install -g grunt-cli + +Browse to the project root directory and install the dev dependencies: + + $ npm install -d + +To execute the build and tests run the following command in the root of the project: + + $ grunt + +You should see a green message in the console: + + Done, without errors. + +###Tests +You can also run the tests in the browser. +Start a test server from the project root: + + $ node test/server.js + +Open the following URL in a browser: + + $ open http://0.0.0.0:8124/test/index.html + +_Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._ + +###Automatic build +You can build automatically after a file change using the following command: + + $ grunt watch diff --git a/cookie/MIT-LICENSE.txt b/cookie/MIT-LICENSE.txt new file mode 100644 index 0000000..8ae647b --- /dev/null +++ b/cookie/MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Copyright 2013 Klaus Hartl + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/cookie/README b/cookie/README deleted file mode 100644 index e69de29..0000000 diff --git a/cookie/README.md b/cookie/README.md new file mode 100644 index 0000000..7377611 --- /dev/null +++ b/cookie/README.md @@ -0,0 +1,146 @@ +# jquery.cookie [![Build Status](https://travis-ci.org/carhartl/jquery-cookie.png?branch=master)](https://travis-ci.org/carhartl/jquery-cookie) + +[![Selenium Test Status](https://saucelabs.com/browser-matrix/carhartl.svg)](https://saucelabs.com/u/carhartl) + +A simple, lightweight jQuery plugin for reading, writing and deleting cookies. + +## Installation + +Include script *after* the jQuery library (unless you are packaging scripts somehow else): + +```html +<script src="/path/to/jquery.cookie.js"></script> +``` + +**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked +in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN. + +The plugin can also be loaded as AMD module. + +## Usage + +Create session cookie: + +```javascript +$.cookie('the_cookie', 'the_value'); +``` + +Create expiring cookie, 7 days from then: + +```javascript +$.cookie('the_cookie', 'the_value', { expires: 7 }); +``` + +Create expiring cookie, valid across entire site: + +```javascript +$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' }); +``` + +Read cookie: + +```javascript +$.cookie('the_cookie'); // => "the_value" +$.cookie('not_existing'); // => undefined +``` + +Read all available cookies: + +```javascript +$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" } +``` + +Delete cookie: + +```javascript +// Returns true when cookie was found, false when no cookie was found... +$.removeCookie('the_cookie'); + +// Same path as when the cookie was written... +$.removeCookie('the_cookie', { path: '/' }); +``` + +*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.* + +## Configuration + +### raw + +By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true: + +```javascript +$.cookie.raw = true; +``` + +### json + +Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`: + +```javascript +$.cookie.json = true; +``` + +## Cookie Options + +Cookie attributes can be set globally by setting properties of the `$.cookie.defaults` object or individually for each call to `$.cookie()` by passing a plain object to the options argument. Per-call options override the default options. + +### expires + + expires: 365 + +Define lifetime of the cookie. Value can be a `Number` which will be interpreted as days from time of creation or a `Date` object. If omitted, the cookie becomes a session cookie. + +### path + + path: '/' + +Define the path where the cookie is valid. *By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior).* If you want to make it available for instance across the entire domain use `path: '/'`. Default: path of page where the cookie was created. + +**Note regarding Internet Explorer:** + +> Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename. + +(From [Internet Explorer Cookie Internals (FAQ)](http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx)) + +This means one cannot set a path using `path: window.location.pathname` in case such pathname contains a filename like so: `/check.html` (or at least, such cookie cannot be read correctly). + +### domain + + domain: 'example.com' + +Define the domain where the cookie is valid. Default: domain of page where the cookie was created. + +### secure + + secure: true + +If true, the cookie transmission requires a secure protocol (https). Default: `false`. + +## Converters + +Provide a conversion function as optional last argument for reading, in order to change the cookie's value +to a different representation on the fly. + +Example for parsing a value into a number: + +```javascript +$.cookie('foo', '42'); +$.cookie('foo', Number); // => 42 +``` + +Dealing with cookies that have been encoded using `escape` (3rd party cookies): + +```javascript +$.cookie.raw = true; +$.cookie('foo', unescape); +``` + +You can pass an arbitrary conversion function. + +## Contributing + +Check out the [Contributing Guidelines](CONTRIBUTING.md) + +## Authors + +[Klaus Hartl](https://github.com/carhartl) diff --git a/cookie/jquery.cookie.js b/cookie/jquery.cookie.js index 61d3bce..9271900 100644 --- a/cookie/jquery.cookie.js +++ b/cookie/jquery.cookie.js @@ -1,91 +1,117 @@ -/*jslint browser: true */ /*global jQuery: true */ - -/** - * jQuery Cookie plugin - * - * Copyright (c) 2010 Klaus Hartl (stilbuero.de) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html +/*! + * jQuery Cookie Plugin v1.4.0 + * https://github.com/carhartl/jquery-cookie * + * Copyright 2013 Klaus Hartl + * Released under the MIT license */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as anonymous module. + define(['jquery'], factory); + } else { + // Browser globals. + factory(jQuery); + } +}(function ($) { -// TODO JsDoc + var pluses = /\+/g; -/** - * Create a cookie with the given key and value and other optional parameters. - * - * @example $.cookie('the_cookie', 'the_value'); - * @desc Set the value of a cookie. - * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); - * @desc Create a cookie with all available options. - * @example $.cookie('the_cookie', 'the_value'); - * @desc Create a session cookie. - * @example $.cookie('the_cookie', null); - * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain - * used when the cookie was set. - * - * @param String key The key of the cookie. - * @param String value The value of the cookie. - * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. - * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. - * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. - * If set to null or omitted, the cookie will be a session cookie and will not be retained - * when the the browser exits. - * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). - * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). - * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will - * require a secure protocol (like HTTPS). - * @type undefined - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.ha...@stilbuero.de - */ + function encode(s) { + return config.raw ? s : encodeURIComponent(s); + } -/** - * Get the value of a cookie with the given key. - * - * @example $.cookie('the_cookie'); - * @desc Get the value of a cookie. - * - * @param String key The key of the cookie. - * @return The value of the cookie. - * @type String - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.ha...@stilbuero.de - */ -jQuery.cookie = function (key, value, options) { - - // key and at least value given, set cookie... - if (arguments.length > 1 && String(value) !== "[object Object]") { - options = jQuery.extend({}, options); - - if (value === null || value === undefined) { - options.expires = -1; - } - - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); - } - - value = String(value); - - return (document.cookie = [ - encodeURIComponent(key), '=', - options.raw ? value : encodeURIComponent(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } - - // key and possibly options given, get cookie... - options = value || {}; - var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; - return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; -}; + function decode(s) { + return config.raw ? s : decodeURIComponent(s); + } + + function stringifyCookieValue(value) { + return encode(config.json ? JSON.stringify(value) : String(value)); + } + + function parseCookieValue(s) { + if (s.indexOf('"') === 0) { + // This is a quoted cookie as according to RFC2068, unescape... + s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); + } + + try { + // Replace server-side written pluses with spaces. + // If we can't decode the cookie, ignore it, it's unusable. + s = decodeURIComponent(s.replace(pluses, ' ')); + } catch(e) { + return; + } + + try { + // If we can't parse the cookie, ignore it, it's unusable. + return config.json ? JSON.parse(s) : s; + } catch(e) {} + } + + function read(s, converter) { + var value = config.raw ? s : parseCookieValue(s); + return $.isFunction(converter) ? converter(value) : value; + } + + var config = $.cookie = function (key, value, options) { + + // Write + if (value !== undefined && !$.isFunction(value)) { + options = $.extend({}, config.defaults, options); + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + return (document.cookie = [ + encode(key), '=', stringifyCookieValue(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // Read + + var result = key ? undefined : {}; + + // 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 $.cookie(). + var cookies = document.cookie ? document.cookie.split('; ') : []; + + for (var i = 0, l = cookies.length; i < l; i++) { + var parts = cookies[i].split('='); + var name = decode(parts.shift()); + var cookie = parts.join('='); + + if (key && key === name) { + // If second argument (value) is a function it's a converter... + result = read(cookie, value); + break; + } + + // Prevent storing a cookie that we couldn't decode. + if (!key && (cookie = read(cookie)) !== undefined) { + result[name] = cookie; + } + } + + return result; + }; + + config.defaults = {}; + + $.removeCookie = function (key, options) { + if ($.cookie(key) !== undefined) { + // Must not alter options, thus extending a fresh object... + $.cookie(key, '', $.extend({}, options, { expires: -1 })); + return true; + } + return false; + }; + +})); diff --git a/cookie/server.js b/cookie/server.js deleted file mode 100644 index 9a91173..0000000 --- a/cookie/server.js +++ /dev/null @@ -1,24 +0,0 @@ -var http = require('http'), - url = require('url'), - path = require('path'), - fs = require('fs'); - -http.createServer(function (request, response) { - var uri = url.parse(request.url).pathname, - filename = path.join(process.cwd(), uri); - - fs.readFile(filename, 'binary', function (err, file) { - if (err) { - response.writeHead(500, { 'Content-Type': 'text/plain' }); - response.write(err + '\n'); - response.end(); - return; - } - - response.writeHead(200); - response.write(file, 'utf-8'); - response.end(); - }); -}).listen(8124, '127.0.0.1'); - -console.log('Server running at http://127.0.0.1:8124/'); diff --git a/cookie/test.html b/cookie/test.html deleted file mode 100644 index cc477f8..0000000 --- a/cookie/test.html +++ /dev/null @@ -1,19 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"> - <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css"> - <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> - <script src="http://code.jquery.com/qunit/git/qunit.js"></script> - <script src="jquery.cookie.js"></script> - <script src="test.js"></script> - <title>jquery.cookie Test Suite</title> - </head> - <body> - <h1 id="qunit-header">jquery.cookie Test Suite</h1> - <h2 id="qunit-banner"></h2> - <div id="qunit-testrunner-toolbar"></div> - <h2 id="qunit-userAgent"></h2> - <ol id="qunit-tests"></ol> - </body> -</html> diff --git a/cookie/test.js b/cookie/test.js deleted file mode 100644 index 4f656c5..0000000 --- a/cookie/test.js +++ /dev/null @@ -1,65 +0,0 @@ -var before = { - setup: function () { - cookies = document.cookie.split('; ') - for (var i = 0, c; (c = (cookies)[i]) && (c = c.split('=')[0]); i++) { - document.cookie = c + '=; expires=' + new Date(0).toUTCString(); - } - } -}; - - -module('read', before); - -test('simple value', 1, function () { - document.cookie = 'c=v'; - equals($.cookie('c'), 'v', 'should return value'); -}); - -test('not existing', 1, function () { - equals($.cookie('whatever'), null, 'should return null'); -}); - -test('decode', 1, function () { - document.cookie = encodeURIComponent(' c') + '=' + encodeURIComponent(' v'); - equals($.cookie(' c'), ' v', 'should decode key and value'); -}); - -test('raw: true', 1, function () { - document.cookie = 'c=%20v'; - equals($.cookie('c', { raw: true }), '%20v', 'should not decode'); -}); - - -module('write', before); - -test('String primitive', 1, function () { - $.cookie('c', 'v'); - equals(document.cookie, 'c=v', 'should write value'); -}); - -test('String object', 1, function () { - $.cookie('c', new String('v')); - equals(document.cookie, 'c=v', 'should write value'); -}); - -test('return', 1, function () { - equals($.cookie('c', 'v'), 'c=v', 'should return written cookie string'); -}); - -test('raw: true', 1, function () { - equals($.cookie('c', ' v', { raw: true }).split('=')[1], - ' v', 'should not encode'); -}); - - -module('delete', before); - -test('delete', 2, function () { - document.cookie = 'c=v'; - $.cookie('c', null); - equals(document.cookie, '', 'should delete with null as value'); - - document.cookie = 'c=v'; - $.cookie('c', undefined); - equals(document.cookie, '', 'should delete with undefined as value'); -}); diff --git a/debian/copyright b/debian/copyright index 10cafbd..a1d1fdf 100644 --- a/debian/copyright +++ b/debian/copyright @@ -68,7 +68,8 @@ License: MIT or GPL Files: cookie/* Copyright: (c) 2010 Klaus Hartl (stilbuero.de) -License: MIT or GPL +Homepage: https://github.com/carhartl/jquery-cookie +License: Expat Files: metadata/* Copyright: (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan diff --git a/debian/rules b/debian/rules index 4edbfeb..04ef473 100755 --- a/debian/rules +++ b/debian/rules @@ -29,6 +29,7 @@ override_dh_auto_build: yui-compressor slides/source/slides.jquery.js -o slides/source/slides.min.jquery.js override_dh_installchangelogs: + dh_installchangelogs --package libjs-jquery-cookie cookie/CHANGELOG.md dh_installchangelogs --package libjs-jquery-livequery livequery/ChangeLog.markdown dh_installchangelogs --package libjs-jquery-uploadify uploadify/Change\ Log.txt dh_installchangelogs --package libjs-jquery-slides slides/README.textile @@ -59,3 +60,7 @@ override_dh_auto_clean: rm -f resize/jquery.ba-resize.min.js rm -f uploadify/jquery.uploadify.min.js rm -f slides/source/slides.min.jquery.js + +override_dh_gencontrol: + dh_gencontrol -plibjs-jquery-cookie -- -v1:1.4.0 + dh_gencontrol --remaining-packages -- 1.8.5.2 _______________________________________________ Pkg-javascript-devel mailing list Pkg-javascript-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-javascript-devel