- Change Summary:
-
Remove oauth-parameter.
- Description:
-
~ Replace gg_oauth_parameter with GList of PurpleKeyValuePair.
~ Replace gg_oauth_parameter with GList of PurpleKeyValuePair.
+ Remove oauth-parameter. - Commit:
-
4c5b90a43ac2c43682760465
Remove gg_oauth_parameter_t
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 |
- Summary:
-
Replace gg_oauth_parameter with GList of PurpleKeyValuePairRemove gg_oauth_parameter_t
- Description:
-
~ Replace gg_oauth_parameter with GList of PurpleKeyValuePair.
~ Use variadic function
gg_oauth_generate_request
instead.- Remove oauth-parameter. - Testing Done:
-
+ Compile.
- Commit:
-
c436827604652bd331397a0e
-
-
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.
-
-
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);
-
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.
-
-
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); }