oSettings.oPreviousSearch.sSearch is not encoded while saving in cookie
oSettings.oPreviousSearch.sSearch is not encoded while saving in cookie
![WhatEver](https://secure.gravatar.com/avatar/71ba367f667e4f7defd33f76814af70f/?default=https%3A%2F%2Fvanillicon.com%2F71ba367f667e4f7defd33f76814af70f_200.png&rating=g&size=120)
Hi all,
I've noticed that the value of oSettings.oPreviousSearch.sSearch is not encoded while saving in cookie with bStateSave enabled. As far as the page charset as well as filter value could be defined not only in UTF or latin, some kind of encoding should be applied (i guess encodeURI/decodeURI should be enough - at least it makes a tric for cyrilic)
WBR,
Andrew
I've noticed that the value of oSettings.oPreviousSearch.sSearch is not encoded while saving in cookie with bStateSave enabled. As far as the page charset as well as filter value could be defined not only in UTF or latin, some kind of encoding should be applied (i guess encodeURI/decodeURI should be enough - at least it makes a tric for cyrilic)
WBR,
Andrew
This discussion has been closed.
Replies
Thanks for noting this - I hadn't really considered what would happen if using a character set other than UTF-x when saving the cookie. Slightly surprised the browser doesn't deal with it for us... So to support other character sets, all that is needed is encodeURI/decodeURI? Are they multi-character set aware? I'm struggling enough with getting TableTools and Flash to work with UTF-16 at the moment... :-)
Regards,
Allan
var oTable;
$(document).ready(function () {
oTable = $('#workbench').dataTable({
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 20,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": true,
"aoColumns": [ {"bSearchable": false}, null, null, {"bSearchable": false} ],
"bStateSave": true
});
$('#tbSearch').keyup(function () {
var searchText = this.value;
oTable.fnFilter(searchText);
});
});
ERROR:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
Timestamp: Wed, 20 Jan 2010 15:42:22 UTC
Message: 'oPreviousSearch.sSearch' is null or not an object
Line: 453
Char: 53
Code: 0
URI: http://localhost:49618/Scripts/jquery.dataTables.min.js
Thanks,
Allan
Looks like its because the table's id is the same as tables I'm using elsewhere. I changed the id and all is good. Might be something to point out in the docs.... Either that or make the cookie use a unique id.
All in all, though, DataTable is a nice piece of kit.
Thanks!
-k
As far as I know encodeUri writes the string as utf-8 and encodes the utf-8 byte stream. Javascript uses UTF-16 internally, where each character is represented by two bytes, with the exception of a certain group which are represented by 4 (2 bytes for the character and 2 bytes for a modifier of that character).
Thus, from my perspective encodeUri/decodeUri or econdeURIComponent/decodeURIComponent (or even escape) would be enough in most scenarios
Kind regards,
Andrew
In DataTables 1.6.1, the cookie value is encoded using encodeURIComponent() - which should make this safe.
Regards,
Allan