Skip to content

Commit

Permalink
use RFC3986 encoding for queries
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Jun 8, 2022
1 parent 649eccd commit b194a48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ additional documentation and more details are available in `man gplaces`. type `
## Statistic
Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
C|1|233|58|1059
C|1|233|58|1064
7 changes: 6 additions & 1 deletion gplaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ static void free_selectors(SelectorList *list) {

static int set_selector_url(Selector *sel, Selector *from, const char *url, const char *input) {
static char buffer[1024];
char *query;
#if defined(GPLACES_USE_LIBIDN2) || defined(GPLACES_USE_LIBIDN)
char *host;
#endif
Expand All @@ -212,7 +213,11 @@ static int set_selector_url(Selector *sel, Selector *from, const char *url, cons
if (curl_url_set(sel->cu, CURLUPART_URL, buffer, CURLU_NON_SUPPORT_SCHEME) != CURLUE_OK) return 0;
}

if (input != NULL && input[0] != '\0' && curl_url_set(sel->cu, CURLUPART_QUERY, input, CURLU_NON_SUPPORT_SCHEME) != CURLUE_OK) return 0;
if (input != NULL && input[0] != '\0') {
if ((query = curl_easy_escape(NULL, input, 0)) == NULL) return 0;
if (curl_url_set(sel->cu, CURLUPART_QUERY, query, CURLU_NON_SUPPORT_SCHEME) != CURLUE_OK) { curl_free(query); return 0; }
curl_free(query);
}

if (curl_url_get(sel->cu, CURLUPART_SCHEME, &sel->scheme, 0) != CURLUE_OK || (!(file = (strcmp(sel->scheme, "file") == 0)) && curl_url_get(sel->cu, CURLUPART_HOST, &sel->host, 0) != CURLUE_OK)) return 0;

Expand Down

0 comments on commit b194a48

Please sign in to comment.