-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add support for parsing JSON in GBK format. #3347
Comments
could you explain the root cause of this issue? Eg. could you share an example of JSON with GBK charset? |
|
Currently, we are adding a prefix location in nginx, where a block of Lua code is used to convert GBK to UTF-8 based on the determined charset type before passing it to ModSecurity for processing. This approach is taken to address the issue. We hope that ModSecurity can directly support the parsing of charset=gbk.
|
first, thanks for pointing out to a possible workaround. Regarding to JSON payload that you mentioned: I can't reproduce the issue. Here is what I did:
sent this JSON file to the server:
Note that I use my Nginx with Albedo as a backend - for more info please read the relevant documentation. And here are the relevant parts of my debug.log:
rule 920230 which checks
so the JSON parser parses the JSON content. I use libmodsecurity3 current master branch:
|
After testing, even if the curl tool specifies charset=GBK in the Content-Type header, the request body content will not automatically perform encoding conversion. Therefore, the 3347.json file content was always sent in UTF-8 encoding during testing. To resolve this, the request body content should first be manually converted to GBK encoding:
|
The application/json content type defaults to supporting charset=UTF-8 parsing. How can it also be made compatible with charset=GBK parsing, such that if UTF-8 parsing fails, it will attempt GBK parsing?
The text was updated successfully, but these errors were encountered: