-
Notifications
You must be signed in to change notification settings - Fork 430
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
Decode url in custom header #2816
Conversation
thanks please take a look at the failing CI jobs. |
d70765e
to
e5edd25
Compare
e5edd25
to
9c32b91
Compare
modules/menu/menu.c
Outdated
char a, b; | ||
while (*src && src < w->p+len) { | ||
if ((*src == '%') && | ||
((a = src[1]) && (b = src[2])) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src[1]) and src[2] can be out of bound here if url is malformed, right? a struct pl is not necessary null terminated. so pl length has to be checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it. Thanks for correcting me.
9c32b91
to
3c01658
Compare
Is it an option to use this function for decode and/or escaping/un-escaping: https://github.com/baresip/re/blob/main/include/re_uri.h#L37 |
modules/menu/menu.c
Outdated
* | ||
* @param w Pl correspond the string is in URL format will be decoded | ||
*/ | ||
void url_decode(struct pl* w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the function is global for the menu module, it should have a menu_
prefix.
you can also move it to the file where it is used, and make it static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I have tried. I will use escaping/un-escaping in re_uri.h as your suggestion above.
can you please clarify what is that function doing ? is it URL encode or decode ? can you add some sample URLs to the documentation ? |
3c01658
to
60653be
Compare
struct mbuf mbe; | ||
err = mbuf_printf(&mbe, "%H", uri_header_unescape, &v); | ||
if (err == 0) { | ||
v.p = (const char *)mbe.buf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mbe
has to be initializedmbuf_printf
allocates memory inmbe.buf
and has to be derefed afterua_add_custom_hdr
- instead of
err
please useret
here
Problem:
utilize /uaaddheader to add a custom header
usage: /uaaddheader =
So that it is impossible to custom header containing space (' ').
My solution:
implement decode URL format before pushing to custom headers