senaite / senaite.core

Enterprise Open Source Laboratory System (LIMS)
https://senaite.com
GNU General Public License v2.0
254 stars 145 forks source link

app.listing search_box encoding issue (CoffeeScript) #2500

Closed toropok closed 8 months ago

toropok commented 8 months ago

Hi,

Due that there is no "issue" section in senaite.app.listing project I'll post it here.

I've encountered with some unexpected behaviour.

When user types into the search-box component of app.listing Cyrillic string and submit search request. The string has being encoded to UTF-8 suddenly.

Screenshot 2024-02-22 at 18 20 09

Further the Python part encodes it again and return as the response.

Seems that response change the state of the component and it's re-renders and resubmit request with non-encoded text (and search performs fine).

Screenshot 2024-02-22 at 18 22 01

Because non-cyrillic text always perform just on request.

We're failed to figure out where the encoding in CoffeeScript happened :) please help where to look that mystical thing

ramonski commented 8 months ago

Hi Leonid, does this cause a problem, so that it does not work?

I guess the issue is related to the functionality that preserves some of the filter/sorting criteria as request parameter and reads it out again here:

https://github.com/senaite/senaite.app.listing/blob/2.x/src/senaite/app/listing/view.py#L702-L709

The magic that does this is located here:

https://github.com/senaite/senaite.app.listing/blob/2.x/webpack/app/listing.coffee#L272-L283

Hope that helps for the beginning.

ramonski commented 8 months ago

Well, it might also be related to this part that causes the encoding:

https://github.com/senaite/senaite.app.listing/blob/2.x/webpack/app/listing.coffee#L117

where the get_url_parameter is here:

https://github.com/senaite/senaite.app.listing/blob/2.x/webpack/app/api.coffee#L44-L60

toropok commented 8 months ago

Aha, well initially we noticed that "Show more" button in the senaite.app.listing component doesn't work at all if filter parameter set as non-latin string.

our investigation led us to the fact that string encodes by browser and this causes this condition assert as true: https://github.com/senaite/senaite.app.listing/blob/2dcccb044cb3f497c64ee96ab7b98ff3816e77af/webpack/app/listing.coffee#L2164

In this code statement encoded value assigns to State and leads to reload.

We'll add PR to fix that.

toropok commented 8 months ago

Fix 141

posted PR

toropok commented 8 months ago

btw same happens to German or Spanish letter as well like in: Übel or bebé

ramonski commented 8 months ago

Thanks for fixing the übel bug!😄