summaryrefslogtreecommitdiff
path: root/shopify.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-22 19:57:48 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-22 19:57:48 +0800
commite257f73b9fb8c5f0aaf8a9b624fc5795becb60e9 (patch)
tree18bc0985b8a0f84d2db7a94e25122f6cc54cb1ec /shopify.c
parent150728762b9673f8cbbe863fcc4bb8e04fbc8db8 (diff)
Might as well use l8w8jwt to decode base64 too
cause that was all we needed gnutls for. Now we can reduce 1 dependency.
Diffstat (limited to 'shopify.c')
-rw-r--r--shopify.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/shopify.c b/shopify.c
index 12e02fb..d26ae85 100644
--- a/shopify.c
+++ b/shopify.c
@@ -3,7 +3,6 @@
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#include <gcrypt.h>
-#include <gnutls/gnutls.h>
#include <toml.h>
#include <curl/curl.h>
#include <json.h>
@@ -372,27 +371,20 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con,
char *host = NULL;
size_t host_len = 0;
- _Bool embedded = 0;
char *dec_host = NULL;
size_t dec_host_len = 0;
+ _Bool embedded = 0;
if (params) {
host = ((struct parameter *)bsearch(&(struct parameter)
{ "host" }, params, nparams,
- sizeof(struct parameter), compare))->val;
+ sizeof(struct parameter),
+ compare))->val;
host_len = strlen(host);
+ l8w8jwt_base64_decode(0, host, host_len, (uint8_t **)&dec_host,
+ &dec_host_len);
param = bsearch(&(struct parameter){ "embedded" }, params,
nparams, sizeof(struct parameter), compare);
embedded = param && !strcmp(param->val, "1");
-
- gnutls_datum_t result;
- gnutls_base64_decode2(&(gnutls_datum_t){
- (unsigned char *)host,
- host_len
- }, &result);
- dec_host_len = result.size;
- dec_host = malloc(dec_host_len + 1);
- strlcpy(dec_host, (const char *)result.data, dec_host_len + 1);
- gnutls_free(result.data);
}
static const char *header_tmpl