From 5485e6a649f83166fd1290843534819662aca0e1 Mon Sep 17 00:00:00 2001 From: Jacob Mealey Date: Tue, 15 Aug 2023 12:42:57 -0400 Subject: [PATCH] update failure test, add error checking for singleurl --- Makefile | 4 ++-- tests.json | 6 +++--- trurl.c | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 67c433df..0bb210ce 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,8 @@ TARGET = trurl OBJS = trurl.o -LDLIBS = $$(curl-config --libs) -CFLAGS += $$(curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g -std=gnu99 +LDLIBS = $$(~/.curl/bin/curl-config --libs) +CFLAGS += $$(~/.curl/bin/curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g -std=gnu99 MANUAL = trurl.1 PREFIX ?= /usr/local diff --git a/tests.json b/tests.json index 9bcec02a..1bce332c 100644 --- a/tests.json +++ b/tests.json @@ -2149,14 +2149,14 @@ "input": { "arguments": [ "--url", - "http://xn--abcdef/", + "http://xn-----/", "--as-idn" ] }, "required": ["punycode2idn"], "expected": { - "stdout": "http://xn--abcdef/\n", - "stderr": "", + "stdout": "", + "stderr": "trurl note: invalid url [Bad hostname]\n", "returncode": 0 } } diff --git a/trurl.c b/trurl.c index 53c209f4..bcca0dea 100644 --- a/trurl.c +++ b/trurl.c @@ -1320,10 +1320,15 @@ static void singleurl(struct option *o, else { /* default output is full URL */ char *nurl = NULL; - if(!geturlpart(o, 0, uh, CURLUPART_URL, &nurl)) { + int rc = geturlpart(o, 0, uh, CURLUPART_URL, &nurl); + if(!rc) { printf("%s\n", nurl); curl_free(nurl); } + else { + VERIFY(o, ERROR_BADURL, "invalid url [%s]", curl_url_strerror(rc)); + url_is_invalid = true; + } } fflush(stdout);