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

Percentage Encode showing weird behaivor #78

Open
x48zhu opened this issue May 19, 2023 · 1 comment
Open

Percentage Encode showing weird behaivor #78

x48zhu opened this issue May 19, 2023 · 1 comment

Comments

@x48zhu
Copy link

x48zhu commented May 19, 2023

Hello, I'm looking at this percentage encoding, where it does this:

  str = str:gsub("\n", "\r\n")
  str = str:gsub("([^%w ,;=_%%%-%.~])", char_to_hex)
  str = str:gsub(" ", "+")

I noticed a weird encoding issue: it encodes journey into jourrney (double r). My suspicion is the first line causes this, even though it doesn't make sense.

This seems to happen only on certain platforms or Lua versions (I'm not sure what triggers that). For example, it didn't happen on my local while running the unit test, but I noticed this issue while on a machine.

This problem stops to happen after I change the code to this:

  str = string.gsub(str, "\r?\n", "\r\n")
  str = string.gsub (str, "([^%w%-%.%_%~%% ,;=])", char_to_hex)
  str = string.gsub (str, " ", "+")
@yangxikun
Copy link
Owner

What's the origin str?
What platform and Lua version causes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants