arturobernalg opened a new pull request, #564:
URL: https://github.com/apache/jspwiki/pull/564

   JSPWIKI-1318: a user preference whose value has a plus sign is lost. 
Choosing the time zone GMT+5 and saving makes the selector show GMT-12, the 
first option, when the page is opened again, and the cookie JSPWikiUserPrefs 
holds GMT 5 with a blank in place of the plus sign. Zones with a minus sign, 
such as GMT-5, are kept.
   
   Cause: the function that reads a cookie in util/cookies.js decodes the value 
and then replaces every plus sign with a blank. The value is written with 
encodeURIComponent, which writes a plus sign as %2B, so the plus sign was lost 
when the preferences were read, and the next save stored the blank.
   
   Change: the plus signs of the raw value are replaced by blanks before it is 
decoded. A blank written by Java, as a plus sign (for example Joe+Bloggs), is 
still read as a blank, and an encoded plus sign (%2B) stays a plus sign. The 
reader is the only line that changes.
   
   Measured in the browser, with the war built from this branch and a Tomcat 
10.1 instance, on a clean cookie jar:
   Before the change: GMT+5 was saved as GMT 5 and the selector showed GMT-12 
after reloading.
   After the change: the editor, the time zone GMT+5 and a time format with 
blanks were still the saved ones after reloading, the cookie held GMT+5 and 
there was one JSPWikiUserPrefs cookie. I saved again without changes, went 
through another page and came back, and the three values were still there.
   I also checked the logic of the old and the new reader on four sample 
values: GMT%2B5 gives GMT 5 with the old one and GMT+5 with the new one, 
a%2Bb%20c gives a b c and a+b c, and Joe+Bloggs and Joe%20Bloggs give the same 
result with both.
   
   Not done: there is no automated test, as the scripts have none in this 
repository. Cookies already saved with the blank stay as they are; the user has 
to choose the zone again. Only Chrome was tried. The ChangeLog has the entry.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to