X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsrwutil.c;h=cb002784c2a2bf48b97b9d8921f52fab20ed50df;hp=5a4f5760ee7865946eb9592a48e4f412edf60736;hb=1d3538f5ffc0a38434e421ae3f2c34618b50d392;hpb=cbe9e3611ef12ee0dd00ce6170d5b46f8a331d8a diff --git a/src/srwutil.c b/src/srwutil.c index 5a4f576..cb00278 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -242,6 +242,8 @@ static void grab_charset(ODR o, const char *content_type, char **charset) *charset = odr_strdup(o, charset_p); while (charset_p[i] && charset_p[i] != sep) { + if (!sep && strchr("; \n\r", charset_p[i])) + break; if (charset_p[i] == '\\' && charset_p[i+1]) i++; (*charset)[j++] = charset_p[i++]; @@ -1050,6 +1052,7 @@ int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, char *name[MAX_SRU_PARAMETERS], *value[MAX_SRU_PARAMETERS]; /* definite upper limit for SRU params */ char *uri_args; char *path; + char *cp; z_HTTP_header_add_basic_auth(encode, &hreq->headers, srw_pdu->username, srw_pdu->password); @@ -1059,10 +1062,15 @@ int yaz_sru_get_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu, hreq->method = "GET"; + cp = strchr(hreq->path, '#'); + if (cp) + *cp = '\0'; + path = (char *) odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 4); - sprintf(path, "%s?%s", hreq->path, uri_args); + sprintf(path, "%s%c%s", hreq->path, strchr(hreq->path, '?') ? '&' : '?', + uri_args); hreq->path = path; z_HTTP_header_add_content_type(encode, &hreq->headers,