I noticed this with IntranetUserJS. To recreate: 1. Add some JS that includes a semicolon to IntranetUserJS: $(document).ready(function() { let my_old_cat = $('#categorycode_entry').val(); console.log(my_old_cat); $('#categorycode_entry').on('change' , function() { let my_new_cat = $('#categorycode_entry').val(); console.log( my_old_cat ); console.log( my_new_cat ); }); }); 2. Save and reload, or check in DB and you'll see this value: $(document).ready(function() { let my_old_cat = $('#categorycode_entry').val() To see in DB you can use: select value from systempreferences where variable = 'IntranetUserJS';
This doesn't effect only CodeMirror system preference but all that allow free text: I tested with AdditionalFieldsInZ3950ResultAuthSearch
diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js index 1b8634951b6..e2b9bcbac8a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js @@ -32,7 +32,7 @@ export class SysprefAPIClient extends HttpClient { .map(variable => sysprefs[variable].length ? sysprefs[variable].map(value => - "%s=%s".format(variable, value) + "%s=%s".format(variable, encodeURIComponent(value)) ) : "%s=".format(variable) )
Created attachment 162778 [details] [review] Bug 36235: Encode system preference data with encodeURIComponent To test: 1. Add some data to a freetext system preference like IntranetUserJS or AdditionalFieldsInZ3950ResultAuthSearch that includes a semicolon; 2. Save the pref and reload the page or check the DB. Everything after the semicolon is removed. 3. Apply patch, try again. Data should remain as is.
I just converted Jonathan's diff into a patch.
(In reply to Lucas Gass from comment #4) > I just converted Jonathan's diff into a patch. Did it fix your problem?
(In reply to Jonathan Druart from comment #5) > (In reply to Lucas Gass from comment #4) > > I just converted Jonathan's diff into a patch. > > Did it fix your problem? Yes.
Created attachment 162975 [details] [review] Bug 36235: Encode system preference data with encodeURIComponent To test: 1. Add some data to a freetext system preference like IntranetUserJS or AdditionalFieldsInZ3950ResultAuthSearch that includes a semicolon; 2. Save the pref and reload the page or check the DB. Everything after the semicolon is removed. 3. Apply patch, try again. Data should remain as is. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
I stumbled upon this by chance while copying intranetuserjs from a live environment to my own local test environment. This should be QAd and/or pushed asap.
Created attachment 163011 [details] [review] Bug 36235: Encode system preference data with encodeURIComponent To test: 1. Add some data to a freetext system preference like IntranetUserJS or AdditionalFieldsInZ3950ResultAuthSearch that includes a semicolon; 2. Save the pref and reload the page or check the DB. Everything after the semicolon is removed. 3. Apply patch, try again. Data should remain as is. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: David Nind <david@davidnind.com>
Adding my sign off as well, in case that will help with QA.
Created attachment 163026 [details] [review] Bug 36235: Encode system preference data with encodeURIComponent To test: 1. Add some data to a freetext system preference like IntranetUserJS or AdditionalFieldsInZ3950ResultAuthSearch that includes a semicolon; 2. Save the pref and reload the page or check the DB. Everything after the semicolon is removed. 3. Apply patch, try again. Data should remain as is. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed for 24.05! Well done everyone, thank you!
Bug 36084 is not in 23.11.x but looks like this can be backported ?
(In reply to Fridolin Somers from comment #13) > Bug 36084 is not in 23.11.x but looks like this can be backported ? I don't think so. koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js does not exist in 23,11,x
(In reply to Pedro Amorim from comment #14) > (In reply to Fridolin Somers from comment #13) > > Bug 36084 is not in 23.11.x but looks like this can be backported ? > > I don't think so. > koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js > does not exist in 23,11,x Yes it exists, since Bug 33289 https://git.koha-community.org/Koha-community/Koha/src/branch/23.11.x/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js
The *vue* file exists, not koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js !
Correct, we now have: koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js This is not great, for many reasons, one of which highlighted just now (it's confusing and redundant).
(In reply to Pedro Amorim from comment #17) > Correct, we now have: > koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js > koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js > > This is not great, for many reasons, one of which highlighted just now (it's > confusing and redundant). As said in other places, I have ofc tried to avoid that but failed. Suggestions are more than welcome!
(In reply to Pedro Amorim from comment #17) > Correct, we now have: > koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js > koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js > > This is not great, for many reasons, one of which highlighted just now (it's > confusing and redundant). Ooohhhh. I need coffee ;)