From: Nathan Wagner Date: Wed, 27 Feb 2019 04:17:57 +0000 (+0000) Subject: send full encoded queries X-Git-Tag: v0.7.0~7 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=6ff53c22d4ab08760c5e8747cd12e4f8bc0b82f6 send full encoded queries --- diff --git a/crypto/rfc3986.re b/crypto/rfc3986.re index feaf49a..ce7ce8a 100644 --- a/crypto/rfc3986.re +++ b/crypto/rfc3986.re @@ -20,7 +20,9 @@ struct tls_uri { char *host; char *port; char *path; + char *encoded_path; char *query; + char *encoded_query; char *fragment; }; @@ -202,6 +204,13 @@ int tls_parse_uri(char *s, struct tls_uri *uri) { } } + if (uri->path) { + uri->encoded_path = strdup(uri->path); + } + if (uri->query) { + uri->encoded_query = strdup(uri->query); + } + percent_decode(uri->host); percent_decode(uri->path); percent_decode(uri->query); @@ -230,5 +239,8 @@ void tls_free_uri(struct tls_uri *uri) { uri->scheme = 0; free(uri->fragment); uri->fragment = 0; - + free(uri->encoded_path); + uri->encoded_path = 0; + free(uri->encoded_query); + uri->encoded_query = 0; } diff --git a/doc/zpm-fetchurl.8 b/doc/zpm-fetchurl.8 index d3948df..6df17c8 100644 --- a/doc/zpm-fetchurl.8 +++ b/doc/zpm-fetchurl.8 @@ -1,4 +1,4 @@ -.TH zpm-fetchurl 8 2019-02-16 "ZPM 0.4" +.TH zpm-fetchurl 8 2019-02-27 "ZPM 0.4" .SH NAME zpm-fetchurl \- download files .SH SYNOPSIS @@ -27,7 +27,7 @@ dependency. output the response header only, implies -r .TP .B \-r -output the entire response header, including the header +output the entire response, including the header .TP .B \-S output the response status code only diff --git a/doc/zpm-pkgdeps.8 b/doc/zpm-pkgdeps.8 index cdda376..ccb06d2 100644 --- a/doc/zpm-pkgdeps.8 +++ b/doc/zpm-pkgdeps.8 @@ -1,19 +1,13 @@ -.TH zpm-pkgdeps 8 2019-02-22 "ZPM 0.3" +.TH zpm-pkgdeps 8 2019-02-26 "ZPM 0.3" .SH NAME zpm-pkgdeps \- run pkgdeps .SH SYNOPSIS - f) pkgfile="$OPTARG" ;; - s) setlist="$setlist $OPTARG"; clearlist=1 ;; - a) add="$add $OPTARG"; ;; - r) remove="$remove $OPTARG" ;; - q) quiet=1 ;; - c) clearlist=1 ;; .B zpm pkgdeps [ .BI \-f " pkgfile" ] [ -.B \-qc +.B \-qcL ] [ .BI \-s " dep" @@ -41,6 +35,9 @@ It is not an error if a dependency to remove is not present. Dependencies are package ids, and thus can't have whitespace or illegal characters. Illegal characters are not checked for, and whitespace will be interpreted as separating dependencies. +.PP +In addition to printing package dependencies, library soname dependencies +will be printed unless the \-L option is given. .SH OPTIONS .TP .BI \-f package diff --git a/src/fetchurl.c b/src/fetchurl.c index 1ef4abd..21e2e66 100644 --- a/src/fetchurl.c +++ b/src/fetchurl.c @@ -22,9 +22,12 @@ struct tls_uri { char *host; char *port; char *path; + char *encoded_path; char *query; + char *encoded_query; char *fragment; }; + int tls_parse_uri(char *, struct tls_uri *); void tls_free_uri(struct tls_uri *); @@ -583,6 +586,7 @@ int main(int ac, char *av[]) { struct tls_buffer request; char lmtime[80]; char *eoh = 0; + char *user_agent = 0; size_t total = 0; size_t header_len; char *url = 0; @@ -591,13 +595,14 @@ int main(int ac, char *av[]) { ltc_mp = tfm_desc; - while ((option = getopt(ac, av, "o:OrIfz:np#R:SkK")) != -1) { + while ((option = getopt(ac, av, "o:OrIfz:np#R:SkKU:")) != -1) { switch (option) { case 'o': outfile = optarg; break; case 'O': calcoutfile = 1; break; case 'S': printstatus = 1; head = 1; break; case 'k': verifypolicy = 0; break; case 'K': verifypolicy = 2; break; + case 'U': user_agent = optarg; break; case 'I': head = 1; case 'r': raw = 1; break; case 'f': failsilent = 1; break; @@ -680,10 +685,18 @@ int main(int ac, char *av[]) { } else { tls_buffer_append(&request, "GET ", 4); } - tls_buffer_append(&request, uri.path, strlen(uri.path)); + tls_buffer_append(&request, uri.encoded_path, strlen(uri.encoded_path)); + if (uri.encoded_query) { + tls_buffer_append(&request, "?", 1); + tls_buffer_append(&request, uri.encoded_query, strlen(uri.encoded_query)); + } tls_buffer_append(&request, " HTTP/1.1\r\n", 11); append_header(&request, "Host", host); + if (user_agent) { + append_header(&request, "User-Agent", user_agent); + } + append_header(&request, "Accept", "*/*"); append_header(&request, "Connection", "close"); if (lmfile) { append_header(&request, "If-Modified-Since", lmtime);