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

change: remove backslash before slash when encoding #7807

Closed
wants to merge 3 commits into from

Conversation

Lewisyixin
Copy link

@Lewisyixin Lewisyixin commented Aug 29, 2022

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 (#7785)
Fixes (#7606)

Checklist

  • I have explained the need for this PR and the problem it solves
  • 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)

@Lewisyixin Lewisyixin marked this pull request as ready for review August 29, 2022 02:40
@tzssangglass tzssangglass changed the title remove backslash before slash when encoding change: remove backslash before slash when encoding Aug 29, 2022
@moonming
Copy link
Member

Is this a break change?

@Lewisyixin
Copy link
Author

Lewisyixin commented Aug 29, 2022

Exactly, I can't guarantee it. The first time I encountered this kind of problem is when dealing with data in etcd((#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 #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.

Copy link
Member

@spacewander spacewander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test like

=== TEST 6: decode/encode empty array
?

@spacewander
Copy link
Member

spacewander commented Aug 29, 2022

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?

@tzssangglass
Copy link
Member

Is this a break change?

Yes, because the format of the json parsing has changed.

@github-actions
Copy link

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 dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 31, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot closed this Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants