[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: fix #6191
From: |
gnunet |
Subject: |
[gnunet] branch master updated: fix #6191 |
Date: |
Tue, 21 Apr 2020 20:48:03 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new bf99d2243 fix #6191
bf99d2243 is described below
commit bf99d2243fedaeb662b5d7b20138cf2ee064a110
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Apr 21 20:43:18 2020 +0200
fix #6191
---
src/curl/curl.c | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/curl/curl.c b/src/curl/curl.c
index da486ecc1..72bb17789 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -525,6 +525,40 @@ GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job)
}
+/**
+ * Test if the given content type @a ct is JSON
+ *
+ * @param ct a content type, i.e. "application/json; charset=UTF-8"
+ * @return true if @a ct denotes JSON
+ */
+static bool
+is_json (const char *ct)
+{
+ const char *semi;
+
+ /* check for "application/json" exact match */
+ if (0 == strcasecmp (ct,
+ "application/json"))
+ return true;
+ /* check for "application/json;[ANYTHING]" */
+ semi = strchr (ct,
+ ';');
+ /* also allow "application/json [ANYTHING]" (note the space!) */
+ if (NULL == semi)
+ semi = strchr (ct,
+ ' ');
+ if (NULL == semi)
+ return false; /* no delimiter we accept, forget it */
+ if (semi - ct != strlen ("application/json"))
+ return false; /* delimiter past desired length, forget it */
+ if (0 == strncasecmp (ct,
+ "application/json",
+ strlen ("application/json")))
+ return true; /* OK */
+ return false;
+}
+
+
/**
* Obtain information about the final result about the
* HTTP download. If the download was successful, parses
@@ -562,8 +596,7 @@ GNUNET_CURL_download_get_result_ (struct
GNUNET_CURL_DownloadBuffer *db,
CURLINFO_CONTENT_TYPE,
&ct)) ||
(NULL == ct) ||
- (0 != strcasecmp (ct,
- "application/json")))
+ (! is_json (ct)))
{
/* No content type or explicitly not JSON, refuse to parse
(but keep response code) */
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: fix #6191,
gnunet <=