Liang2580 / lua-resty-cookie-parser

lua-resty-cookie-parser
https://github.com/Liang2580/lua-resty-cookie-parser
0 stars 0 forks source link

Is this library tested in real life? #1

Open amdei opened 1 year ago

amdei commented 1 year ago
  1. Looking at source code I've noticed a lot of global variables. lua-nginx-module complains on them, offering to consider to make them local.

  2. Upon parsing it keeps spaces in front of cookie names

  3. Cookie values with = signs in them being parsed incorrectly.

  4. Strange (for me) format of return values

  5. Method names with 2 at the end? Why?

  6. Probably something else...

Liang2580 commented 1 year ago
  1. Looking at source code I've noticed a lot of global variables. lua-nginx-module complains on them, offering to consider to make them local.
  2. Upon parsing it keeps spaces in front of cookie names
  3. Cookie values with = signs in them being parsed incorrectly.
  4. Strange (for me) format of return values
  5. Method names with 2 at the end? Why?
  6. Probably something else...

Thank you for your question

Tested.

Why did you not add local because changes within a function do not go global.

  1. If there are parsing errors, can you please send a payload and I will fix it on my end

  2. The format of the return value is reserved because it includes all double names.

  3. The method name is at the end. This is in habit

amdei commented 1 year ago

Thanks for a prompt reply!

  1. I'd better make local variables local to ensure there will be no frightening errors in nginx's logs. Does MR will be considered to review?
  2. Spaces: Input: Cookie: totally_insecure=steal+me!; _ym_uid=1688391939759575606; _ym_d=1688391939 Outpup will be something like this: JJ: [{"totally_insecure":"steal+me!"},{" _ym_uid":"1688391939759575606"},{" _ym_d":"1688391939"}] Note: spaces in front of ym
  3. Equal signs: Cookie: myauth=kqTNyMss9lYT5LqaK934zL/rAwZjfs8lurnjlgh1ilk=:Z+YiiE8c/PcX0GqajKrMJWjencAGg+HHtvtRzRE+qAQ= Outpup will be something like this: [{" myauth":"kqTNyMss9lYT5LqaK934zL/rAwZjfs8lurnjlgh1ilk :Z+YiiE8c/PcX0GqajKrMJWjencAGg+HHtvtRzRE+qAQ "}] Note: both equal signs (=) has disappeared from cookie value.
  4. Oh.. I see... Thanks for clarifications! What about cookie attributes? Or they are not being sent by client?