laravel-datatables icon indicating copy to clipboard operation
laravel-datatables copied to clipboard

fix: encode search keyword

Open yajra opened this issue 2 years ago • 7 comments

Fix #2901

yajra avatar Nov 17 '22 07:11 yajra

Note: need to review as encoding the keyword is a change in behavior and might cause a breaking change.

yajra avatar Nov 18 '22 09:11 yajra

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
48.1% 48.1% Duplication

sonarqubecloud[bot] avatar Nov 22 '22 01:11 sonarqubecloud[bot]

@dyaskur thanks for the review. However, adding is_encoded:true in the script will not affect the serverSide implementation as the js library will not send it back in the ajax request.

How about if we add another control on a column level that toggles encoded search? Maybe something like:

->encodedSearch(['col1', 'col2'])

yajra avatar Dec 30 '22 01:12 yajra

I see, I thought datatable will send all column attribute to the ajax request. If can't send by client side, we need to set it on server side. And I think your idea looks good.

dyaskur avatar Dec 30 '22 15:12 dyaskur

@yajra , recently came up with a similar solution while debugging a weird behavior with the collection as a source. This change adds equality to a search input and modified collection at DataProcessor escapeRow which uses laravel's e() func. Any estimates on when this will be merged?

aravael avatar Feb 16 '23 12:02 aravael

@aravael, would you be able to test this and see the impact on your existing project? Would you approve this PR?

yajra avatar Feb 20 '23 09:02 yajra

Hi @yajra . Recently managed to test it, can't approve this patch. Though it fixes the collection search, it breaks the builder source. Since we sanitize the input with e(), the database data are still not modified, therefore not found the result.

It works with a collection because both the collection and input sanitized. In case of builder source it doesn't work that way. Need to process that out.

aravael avatar Feb 28 '23 09:02 aravael