From e25b377ee84b0681356a63ef8b0a11edd5adedc4 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Thu, 13 Sep 2012 18:13:32 +0100 Subject: [PATCH] Fix: State saving deletion of cookies was somewhat broken. It would delete cookies out of order, which is not what we want. Rewrite how the 'overage' of cookies (4K limit) is handled --- media/js/jquery.dataTables.js | 49 +++++++++++++++++++++++------------ media/src/core/core.state.js | 49 +++++++++++++++++++++++------------ 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 00fdfe85..3e44b3bb 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -4508,35 +4508,50 @@ } /* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies - * belonging to DataTables. This is FAR from bullet proof + * belonging to DataTables. */ - var sOldName="", iOldTime=9999999999999; - var iLength = _fnReadCookie( sNameFile )!==null ? document.cookie.length : - sFullCookie.length + document.cookie.length; + var + aCookies =document.cookie.split(';'), + iNewCookieLen = sFullCookie.split(';')[0].length, + aOldCookies = []; - if ( iLength+10 > 4096 ) /* Magic 10 for padding */ + if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */ { - var aCookies =document.cookie.split(';'); for ( var i=0, iLen=aCookies.length ; i 4096 ) /* Magic 10 for padding */ + if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */ { - var aCookies =document.cookie.split(';'); for ( var i=0, iLen=aCookies.length ; i