Since the new way of receiving orders in 23.11, the receiving of an order is impossible when this order was created from a purchase suggestion and the reason for accepting the suggestion contains an apostrophe. I didn't test all possible characters. Exclamation and question marks, comma's and semicolons all seem fine. Temporary workaround is to edit the suggestion were the order came from and remove the apostrophe. However, by editing the suggestion, the patron who made the suggestion will get another automatic notice that the title has been ordered and the library will get another email that a suggestion was made, so not ideal. And it slows down the acquisition process.
I have had several complaints about this from clients since we upgraded them. Here is the test plan to recreate the problem: 1. Create a suggestion 1.1. Go to Acquisitions > Suggestions 1.2. Click New purchase suggestion 1.3. Enter a title 1.4. Click Submit your suggestion 2. Update the suggestion to accepted and add a reason with an apostrophe 2.1. In the suggestions list, check the box next to the suggestion 2.2. At the bottom of the screen, choose Mark selected as: Accepted 2.3. In With this reason, choose Others... 2.4. Enter a reason with an apostrophe (my case was in French : Disponible en impression à la demande (POD). S'attendre à un long temps d'attente) 2.5. Click Submit 3. Order the suggestion 3.1. Go to Acquisitions 3.2. Search for a vendor 3.3. Click New > Basket 3.4. Enter a basket name (Optional: for testing I like to change Create items when: cataloging the record) 3.5. Click Save 3.6. Click Add to basket 3.7. Click From a suggestion 3.8. Click Order next to the suggestion 3.9. Enter order details 3.10. Click Save 3.11. Click Close basket 3.12. Click Yes, close 4. Receive the order 4.1. Click Receive shipments 4.2. Enter a Vendor invoice number 4.3. Click Next 4.4. Click Receive next to the order --> Page stays In processing forever I upped the severity to major as this causes a functionality to not work at all (acquisitions receive), but there is a workaround (remove the apostrophe), so not critical.
Created attachment 162243 [details] [review] Bug 36047: Workaround the apostrophe This is just a quick hack fix highlighting where the issue lies the real fix should be escape HTML entities coming from biblio.suggestions as this fix may also fail in case the data contains double quotes
I may come back to this but I'm out of time for now so just wanted to submit the result of my dig through.
Created attachment 162280 [details] [review] Bug 36047: Add apos and quot to escapeHtml core function
Created attachment 162281 [details] [review] Bug 36047: filter jQuery selector through escapeHtml
Created attachment 162285 [details] [review] Bug 36047: filter jQuery selector through escapeHtml Signed-off-by: Phan Tung Bui <phan-tung.bui@inlibro.com>
With the patch applied, if the reason selected is one from the SUGGEST authorised value category, and this reason has an apostrophe, on the receive modal the reason is displayed inside a text input, instead of the select. I think it's due to the fact that the selector `option[value="l'apostrophe"]` will not match <option value="l'apostrophe">. A properly escaped selector would be `option[value="l\'apostrophe"]` We should do something like this instead: - if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) { + const options = Array.from(document.querySelectorAll('#reason option')) + if (options.some(option => option.value === row.biblio.suggestions[0].reason)) { No need to escape anything
Created attachment 162337 [details] [review] Bug 36047: Remove jQuery selector from conditional This prevents the jQuery from breaking if the reason contains an apostrophe character. 1. Create a suggestion 1.1. Go to Acquisitions > Suggestions 1.2. Click New purchase suggestion 1.3. Enter a title 1.4. Click Submit your suggestion 2. Update the suggestion to accepted and add a reason with an apostrophe 2.1. In the suggestions list, check the box next to the suggestion 2.2. At the bottom of the screen, choose Mark selected as: Accepted 2.3. In With this reason, choose Others... 2.4. Enter a reason with an apostrophe (my case was in French : Disponible en impression à la demande (POD). S'attendre à un long temps d'attente) 2.5. Click Submit 3. Order the suggestion 3.1. Go to Acquisitions 3.2. Search for a vendor 3.3. Click New > Basket 3.4. Enter a basket name (Optional: for testing I like to change Create items when: cataloging the record) 3.5. Click Save 3.6. Click Add to basket 3.7. Click From a suggestion 3.8. Click Order next to the suggestion 3.9. Enter order details 3.10. Click Save 3.11. Click Close basket 3.12. Click Yes, close 4. Receive the order 4.1. Click Receive shipments 4.2. Enter a Vendor invoice number 4.3. Click Next 4.4. Click Receive next to the order --> Page stays In processing forever Apply patch. Repeat. Notice the page now renders correctly. Extra: Add an entry containg an apostrophe to the SUGGEST authorized values category and repeat test plan. Confirm everything works as expected. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
(In reply to Julian Maurice from comment #7) > With the patch applied, if the reason selected is one from the SUGGEST > authorised value category, and this reason has an apostrophe, on the receive > modal the reason is displayed inside a text input, instead of the select. > I think it's due to the fact that the selector > `option[value="l'apostrophe"]` will not match <option > value="l'apostrophe">. A properly escaped selector would be > `option[value="l\'apostrophe"]` > > We should do something like this instead: > > - if($("#reason > option[value='"+row.biblio.suggestions[0].reason+"']").length) { > + const options = Array.from(document.querySelectorAll('#reason option')) > + if (options.some(option => option.value === > row.biblio.suggestions[0].reason)) { > > No need to escape anything Thank you Julian, my solution fixed the reported issue but broke functionality as you've described. I was able to reproduce the issue my patch introduced, tested your suggestion and confirmed it fixes it. I've submitted the patch authored by you with my SO.
Created attachment 162361 [details] [review] Bug 36047: Remove jQuery selector from conditional This prevents the jQuery from breaking if the reason contains an apostrophe character. 1. Create a suggestion 1.1. Go to Acquisitions > Suggestions 1.2. Click New purchase suggestion 1.3. Enter a title 1.4. Click Submit your suggestion 2. Update the suggestion to accepted and add a reason with an apostrophe 2.1. In the suggestions list, check the box next to the suggestion 2.2. At the bottom of the screen, choose Mark selected as: Accepted 2.3. In With this reason, choose Others... 2.4. Enter a reason with an apostrophe (my case was in French : Disponible en impression à la demande (POD). S'attendre à un long temps d'attente) 2.5. Click Submit 3. Order the suggestion 3.1. Go to Acquisitions 3.2. Search for a vendor 3.3. Click New > Basket 3.4. Enter a basket name (Optional: for testing I like to change Create items when: cataloging the record) 3.5. Click Save 3.6. Click Add to basket 3.7. Click From a suggestion 3.8. Click Order next to the suggestion 3.9. Enter order details 3.10. Click Save 3.11. Click Close basket 3.12. Click Yes, close 4. Receive the order 4.1. Click Receive shipments 4.2. Enter a Vendor invoice number 4.3. Click Next 4.4. Click Receive next to the order --> Page stays In processing forever Apply patch. Repeat. Notice the page now renders correctly. Extra: Add an entry containg an apostrophe to the SUGGEST authorized values category and repeat test plan. Confirm everything works as expected. Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Pushed for 24.05! Well done everyone, thank you!
Pushed to 23.11.x for 23.11.04
Backported to 23.05.x for upcoming 23.05.10