arturobernalg opened a new pull request, #561: URL: https://github.com/apache/jspwiki/pull/561
JSPWIKI-851: when the session has expired, the save is refused and the text typed in the editor is lost. Cause: SpamFilter.checkHash redirects to the page SessionExpired when the hash field of the form is missing, and saves nothing. The submit handler in Wiki.Edit.js had already removed the draft that the editor keeps in the local storage of the browser, so nothing was left to restore. Also, no page SessionExpired exists in the initial pages, so the user saw that the page does not exist. Change: the submit handler now only marks the draft as sent in the session storage. In Wiki.js, the next page that is loaded consumes the mark and removes the draft only when that page is the view of the saved page. After a refused save the draft stays, and the editor offers to restore it. A page SessionExpired is added to the English initial pages; the markdown copy is generated by the build. Measured in the browser with the war built from this branch, on a Tomcat 10.1 instance, with the plain editor: Normal save: the draft and the mark are removed when the saved page is shown, and opening the editor again shows no restore dialog. Refused save (I removed the hash field from the form before pressing Save, which is what a missing hash looks like to checkHash): the browser goes to SessionExpired, which shows the new text, the draft is kept, and viewing the page afterwards does not remove it. Opening the editor again shows the restore dialog, and restoring puts the typed text back in the editor and the preview. My first version removed the draft when the page itself was viewed after the refused save; I found it with this test and changed the mark to be consumed by the first page that loads. Not done: there is no automated test, as the scripts have none in this repository. I did not wait for a real expiry of the session, only the plain editor and Chrome were tried, and pages for the other languages are not added. -- 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]
