Change Summary:
Remove oauth-parameter.
Description: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||
Diff: |
Revision 2 (+69 -217) |
Review Request #516 — Created Feb. 15, 2021 and discarded
Use variadic function
gg_oauth_generate_request
instead.
Compile.
Description | From | Last Updated |
---|---|---|
Since gg_oauth_parameter_set is only called in a block with gg_oauth_parameter_join right after it, I feel like a variadic gg_oath_parameter_generate(gboolean header, … |
QuLogic | |
Mark with G_GNUC_NULL_TERMINATED |
QuLogic | |
And then add NULL at the end. |
QuLogic | |
Ditto. |
QuLogic | |
A comment about how this works, ie returning a comma separated header value if header is true, or a url-encoded … |
grim | |
curious why g_string_append_printf wasn't used? |
grim | |
This might read a bit better and lead to less errors later as right now there's 3 checks for header … |
grim | |
We can but I don't see how g_string_truncate() can lead to memory errors. |
qarkai | |
I just realized this is to handel the trailing , or & from line 83. This can lead to memory … |
grim | |
I was thinking of something more like this for this function... static char * gg_oauth_generate_request(gboolean header, ...) { GString *res … |
grim |
Remove oauth-parameter.
Description: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||
Diff: |
Revision 2 (+69 -217) |
libpurple/protocols/gg/oauth/oauth.c (Diff revision 2) |
---|
Since
gg_oauth_parameter_set
is only called in a block withgg_oauth_parameter_join
right after it, I feel like a variadicgg_oath_parameter_generate(gboolean header, ...)
might be simpler.
Summary: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
|||||||||
Testing Done: |
|
|||||||||
Commit: |
|
|||||||||
Diff: |
Revision 3 (+54 -224) |
libpurple/protocols/gg/oauth/oauth.c (Diff revision 4) |
---|
A comment about how this works, ie returning a comma separated header value if header is true, or a url-encoded value would be nice.
libpurple/protocols/gg/oauth/oauth.c (Diff revision 4) |
---|
curious why
g_string_append_printf
wasn't used?
libpurple/protocols/gg/oauth/oauth.c (Diff revision 4) |
---|
This might read a bit better and lead to less errors later as right now there's 3 checks for header to be true.
escaped = g_uri_escape_string(value, NULL, FALSE); if(header) { g_string_append_printf(res, "\"%s\",", escaped); } else { g_string_append_printf(res, "%s&", escaped); } g_free(escaped);
libpurple/protocols/gg/oauth/oauth.c (Diff revision 4) |
---|
I just realized this is to handel the trailing
,
or&
from line 83. This can lead to memory errors. Can we instead have a boolean to say whether or not we've processed the first item, and if so, then prefix it.
libpurple/protocols/gg/oauth/oauth.c (Diff revision 4) |
---|
We can but I don't see how
g_string_truncate()
can lead to memory errors.
Reduce
header
checks.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+59 -224) |
libpurple/protocols/gg/oauth/oauth.c (Diff revision 5) |
---|
I was thinking of something more like this for this function...
static char * gg_oauth_generate_request(gboolean header, ...) { GString *res = g_string_new(NULL); va_list params; if(header) { res = g_string_append(res, "OAuth "); } va_start(params, header); while((key = va_arg(params, const gchar *))) { const gchar *value = va_arg(params, const gchar *); gchar *escaped = g_uri_escape_string(value, NULL, FALSE); if(header) { g_string_append_printf(res, "\"%s\",", escaped); } else { g_string_append_printf(res, "%s&", escaped); } g_free(escaped); } va_end(params); if(res->len > 0 && res->str[res->len - 1] == separator) { /* remove trailing separator */ res = g_string_truncate(res, res->len - 1); } return g_string_free(res, FALSE); }