Hello guys,
I'm trying to make a plugin work so that it stores a boolean value in a
cookie reads it on startup. It ended up working in FireFox, Safari and IE.
While for Chrome it's ok (from the point of view of TiddlyWiki core) [1],
the behaviour in Opera "is not intendent".
Some searching led me to this question [2] which was answered: "Double
quotes are formally illegal in a cookie value. If you escape them as %22 it
will work." So I suspected that that's the case for TiddlyWiki as well.
Writing in FireBug console
var key,cookies = {};
for(key in config.options) {
var value = getOption(key);
value = value == null ? 'false' : value;
cookies[key] = value;
}
document.cookie = 'TiddlyWiki=' + String.encodeHashMap(cookies) + ';
expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/';
getCookies()
gave me a hashmap with a "TiddlyWiki" item with value containing double
quotes (around each option value). So the saveCookie function [3] works
incorrectly and either String.encodeHashMap [4] should be changed so that
it uses single quotes instead of double quotes; or encoding/decoding should
be introduced into saveOption and loadCookies. An example can be found in
[5].
What do you think?
Best regards,
Yakov.
[1]
http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies
[2]
http://stackoverflow.com/questions/11869902/cookies-not-being-sent-back-and-forth-properly-in-opera
[3] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Options.js#L108
[4] https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/Strings.js#L253
[5] https://developer.mozilla.org/en-US/docs/Web/API/document.cookie ,
starting from "A little framework"
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.