change: remove backslash before slash when encoding
Description
Remove backslash before slash when setting routes to etcd or generating log to local files. The backslash is from lua-cjson and it can be turned off by default. https://github.com/openresty/lua-cjson/#encode_escape_forward_slash
Fixes (https://github.com/apache/apisix/issues/7785) Fixes (https://github.com/apache/apisix/discussions/7606)
Checklist
- [x] I have explained the need for this PR and the problem it solves
- [x] I have explained the changes or the new features added to this PR
- [ ] I have added tests corresponding to this change
- [ ] I have updated the documentation to reflect this change
- [ ] I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)
Is this a break change?
Exactly, I can't guarantee it. The first time I encountered this kind of problem is when dealing with data in etcd((https://github.com/apache/apisix/discussions/7606)) . Then I found it was caused by lua-json and avoid it by turning off json.encode_escape_forward_slash in my own plugin next time.
When I found other people meeting the same problem in https://github.com/apache/apisix/issues/7785 I helped them by json.encode_escape_forward_slash and asked spacewander if this param can be default turned off in apisix.core.json to avoid backslash before slash when json encoding. He let me to try to submit a PR.
I learned this param from https://github.com/openresty/lua-cjson/#encode_escape_forward_slash and used it in my plugin for some months. But determining whether it will affect other components in apisix is maybe beyond my ability.
There are some broken tests: https://github.com/apache/apisix/runs/8062783800?check_suite_focus=true https://github.com/apache/apisix/runs/8062783743?check_suite_focus=true
I have checked them and all of them are about extra \ before / in the expected string.
Would you please update the test cases?
Is this a break change?
Yes, because the format of the json parsing has changed.
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the [email protected] list. Thank you for your contributions.
This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.