Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toJson causes encoding of utf-8 characters #3119

Closed
avatarofhope2 opened this issue Feb 15, 2024 · 6 comments
Closed

toJson causes encoding of utf-8 characters #3119

avatarofhope2 opened this issue Feb 15, 2024 · 6 comments

Comments

@avatarofhope2
Copy link

avatarofhope2 commented Feb 15, 2024

Summary of problem or feature request

When selecting data with valid utf-8 characters, the JsonResponse html encodes the data. I can disable this by using the rawColumns method, but I do want it to escape html specific things, just not normal characters that would not have an impact on xss. I think that maybe characters like ' (' or U+0027) should maybe be unmangled by default. My apologies if I've overlooked something or this has been addresses since version 8. I searched around in the issues, and while I did find some issues related to this, I didn't spot anything specific to this issue.

Code snippet of problem

return DataTables::eloquent(MyModel::select())->toJson();

data that shows the issue: "COEUR-D'ALENE" is returned as "COEUR-D'ALENE-ID"

System details

  • Centos 7
  • PHP 7.2
  • 5.6
  • 8
@github-actions github-actions bot added the stale label Mar 18, 2024
@yajra yajra added for review and removed stale labels Mar 18, 2024
Repository owner deleted a comment from github-actions bot Mar 18, 2024
@yajra
Copy link
Owner

yajra commented Mar 18, 2024

I think you need to use rawColumns?

@avatarofhope2
Copy link
Author

I am using rawColumns, but it could be a security issue, if the column data could contain html/javascript, right? I'm trying to establish a difference between utf-8 and html when it comes to encoding data from the database.

@github-actions github-actions bot added the stale label May 3, 2024
Repository owner deleted a comment from github-actions bot May 3, 2024
@yajra yajra removed the stale label May 3, 2024
@yajra
Copy link
Owner

yajra commented May 3, 2024

Yes, rawColumns will also allow the js script. Maybe try using the column.render api.

@avatarofhope2
Copy link
Author

I appreciate the thought, but I tend to re-use these APIs for more than just datatables front-ends, so I'd prefer to get just the exact utf-8 data as-is, except if there is html/js which could pose a security risk.

Copy link

github-actions bot commented Jun 3, 2024

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Jun 3, 2024
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants