-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add a flag when decoded args are truncated #543
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
base: master
Are you sure you want to change the base?
Conversation
@hamishforbes An additional return value can break backward compatibility, for example,
will not work as expected because the second argument now becomes the 3rd, leading to (kindy) hard-to-debug issues. We need to figure out a better way without breaking existing user code. |
Ah, that is a good point, didn't think of that! We could add another argument that toggles returning this flag, e.g. The main issue is the args get truncated silently which can lead to odd issues when passing on request to other systems. I think it would be preferable to allow the user to handle it themselves rather than log something but at least it would be clear what has happened. |
@hamishforbes You beat me :) Another flag argument looks artificial to me as well. I would have a hard time documenting this argument if we implemented it. Raising default error log level for the logging can open a door for malicious clients to flush your nginx error logs which can be very expensive because error logging is never buffered (for obvious reasons). Maybe adding a new configuration directive to allow the user to change the level? Still a bit cumbersome but a bit better than messing up the Lua API :) What do you think? (Sorry) |
Do you mean adding an option similar to The only other approach I can think of would be to add something like |
@hamishforbes Oh, seems like there's another way. How about adding an empty metatable to the resulting table in case of truncation? This won't break existing code I suppose and you have a way to handle this case in Lua yourself. |
I'm not entirely sure I follow, do you mean setting the metatable to |
@hamishforbes Yes. |
That sounds like a better solution. I'm pretty new to the Lua C API but am I right in thinking this is as simple as
|
@hamishforbes Instead of creating a new table upon every call, we could reuse and share a single empty table. It's supposed to be read-only anyway. |
Whats the best way to go about doing that? Or is there somewhere else in the codebase you've already used that technique? |
@hamishforbes Maybe you can find this helpful: http://www.lua.org/manual/5.1/manual.html#luaL_newmetatable |
Ah missed that one! Sounds like repeatedly calling luaL_newmetatable doesn't create a new table each time, so that should be fine? Do you have any preference for naming of metatables like this, there doesn't seem to be any others in the current codebase. I'll update and push tests/docs if you're happy with this approach. |
@hamishforbes Yes. Please go ahead :) Though I'm still not 100% happy with this approach ;) |
Ok cool, thanks for the pointers! |
e7ac10c
to
cfd4f90
Compare
This pull request is now in conflict :( |
f924579
to
fef2581
Compare
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
Currently there's no way to tell if
ngx.decode_args
,ngx.req.get_uri_args
orngx.req.get_post_args
silently discard arguments without enabling debug logging.This change adds a second boolean return value to indicate if arguments have been truncated.