gigebyte / cookies

Automatically exported from code.google.com/p/cookies
0 stars 0 forks source link

cookify and cookieFill issues with encoding and id, name order #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps reproduce the problem?
1. I have a checkbox which is using id and name. Basicaly those are
generated by ASP. To select the checkbox I use $('#textConcatenate
input').cookieBind();

What is the expected result of the above steps?  What do you see instead?
The checkbox works when I reload the page

What version of the following are you using?
  jQuery: 1.4.2
  cookies: 2.2.0

What browser/version are you using?

Firefox 3.6.3

What OS/version are you using?

Windows XP

Do you have any additional information to provide?

I have done some testing on the code, and found out that in the cookieFill
method the 

value = $.cookies.get(name); 

does not return the value

I though maybe it is because I use the name and id at the same time.

So I changed the order of nameAttr = ['name', 'id'] to id, name. Now it
works fine.

var n, getN, nameAttrs = ['id', 'name'], name, $this = $(this), value;

Another issue with select option fields. I was wondering why it did not
work, and doing the same testing i found out that the value set up in the
cookies is not encoded. Because in the value I have "+" characted and when
the script in cookieFill method tries to get the value of cookie, the "+"
char is excluded. So I found the issue using the encodeURIComponent.

I have changed in the cookieFill 

value = $.cookies.get(name); 

to 

value = decodeURIComponent($.cookies.get(name)); 

and in cookify

$.cookies.set(name, value, options);

to 

$.cookies.set(name, encodeURIComponent(value), options);

Hope I wrote something useful :)

Original issue reported on code.google.com by sourn...@gmail.com on 8 Apr 2010 at 4:20

GoogleCodeExporter commented 9 years ago
Hello and thanks for reporting your issues.

The issue you describe is already reported in Issue #19

The second is something I need to take a close look at, because the library is 
already using 
encode/decodeURIComponent internally.  I'll test and report back to you what I 
found.

Original comment by auldrid...@gmail.com on 8 Apr 2010 at 4:33

GoogleCodeExporter commented 9 years ago
I cannot reproduce your second issue (which require you to add a call to 
encodeURIComponent). Do you have any code to show? Maybe an example you can 
paste to http://jsfiddle.net

Thanks
Jim

Original comment by auldrid...@gmail.com on 27 Jan 2011 at 4:50