diff --git a/net/trurl/Makefile b/net/trurl/Makefile new file mode 100644 index 00000000000..60046e58427 --- /dev/null +++ b/net/trurl/Makefile @@ -0,0 +1,39 @@ +COMMENT= command line tool for URL parsing and manipulation + +DISTNAME= trurl-0.16.1 +CATEGORIES= net +HOMEPAGE= https://curl.se/trurl/ + +MAINTAINER= David Leadbeater + +# MIT +PERMIT_PACKAGE= Yes + +WANTLIB= c curl + +SITES= https://curl.se/trurl/dl/ + +MODULES= lang/python +MODPY_BUILDDEP= No +MODPY_RUNDEP= No + +BUILD_DEPENDS= shells/bash +LIB_DEPENDS= net/curl +TEST_DEPENDS= ${MODPY_RUN_DEPENDS} + +# install target combines PREFIX and DISTDIR, this puts the files in the +# correct location. +FAKE_FLAGS= PREFIX="${TRUEPREFIX}"\ + MANDIR="${TRUEPREFIX}/man/man1" + +TEST_FLAGS= PYTHON3=${MODPY_BIN} + +USE_GMAKE= Yes +CONFIGURE_STYLE= none + +ALL_TARGET= all completions + +post-extract: + sed -i 's,/bin/bash,${LOCALBASE}/bin/bash,' ${WRKSRC}/scripts/*.sh + +.include diff --git a/net/trurl/distinfo b/net/trurl/distinfo new file mode 100644 index 00000000000..eac95260256 --- /dev/null +++ b/net/trurl/distinfo @@ -0,0 +1,2 @@ +SHA256 (trurl-0.16.1.tar.gz) = qslH1PtCGlirwZo3ceh5Qs1HIbj4VcQzR4yUwRqCA7o= +SIZE (trurl-0.16.1.tar.gz) = 64088 diff --git a/net/trurl/patches/patch-Makefile b/net/trurl/patches/patch-Makefile new file mode 100644 index 00000000000..a18f8e5c464 --- /dev/null +++ b/net/trurl/patches/patch-Makefile @@ -0,0 +1,24 @@ +add DESTDIR to completion install (backport of https://github.com/curl/trurl/commit/0ce73c17cb865db0df424d410ea6a7b808e89067) +fix path of completions (upstream bbb62f7f05af1365c7f12645fcc77b6ac7538439) + +Index: Makefile +--- Makefile.orig ++++ Makefile +@@ -39,7 +39,7 @@ PREFIX ?= /usr/local + BINDIR ?= $(PREFIX)/bin + MANDIR ?= $(PREFIX)/share/man/man1 + ZSH_COMPLETIONSDIR ?= $(PREFIX)/share/zsh/site-functions +-COMPLETION_FILES=scripts/_trurl.zsh ++COMPLETION_FILES=completions/_trurl.zsh + + INSTALL ?= install + PYTHON3 ?= python3 +@@ -64,7 +64,7 @@ install: + fi) + (if test -f $(COMPLETION_FILES); then \ + $(INSTALL) -d $(DESTDIR)$(ZSH_COMPLETIONSDIR); \ +- $(INSTALL) -m 0755 $(COMPLETION_FILES) $(ZSH_COMPLETIONSDIR)/_trurl; \ ++ $(INSTALL) -m 0755 $(COMPLETION_FILES) $(DESTDIR)$(ZSH_COMPLETIONSDIR)/_trurl; \ + fi) + + .PHONY: clean diff --git a/net/trurl/patches/patch-test_py b/net/trurl/patches/patch-test_py new file mode 100644 index 00000000000..ad37c8c9896 --- /dev/null +++ b/net/trurl/patches/patch-test_py @@ -0,0 +1,24 @@ +Handle uppercase URL escapes in tests, backport of +https://github.com/curl/trurl/commit/f22a2c45956f35702e437fb83ac05376f1956ec5 + +Index: test.py +--- test.py.orig ++++ test.py +@@ -250,11 +250,16 @@ def main(argc, argv): + print(f"Missing feature, skipping test {testIndex + 1}.") + numTestsSkipped += 1 + continue ++ excludes = allTests[testIndex].get("excludes", None) ++ if excludes and set(excludes).issubset(set(features)): ++ print(f"Test not compatible, skipping test {testIndex + 1}") ++ numTestsSkipped += 1 ++ continue + encoding = allTests[testIndex].get("encoding", None) + if encoding and encoding != getcharmap(): + print(f"Invalid locale, skipping test {testIndex + 1}.") + numTestsSkipped += 1 +- continue; ++ continue + + test = TestCase(testIndex + 1, runnerCmd, baseCmd, **allTests[testIndex]) + diff --git a/net/trurl/patches/patch-tests_json b/net/trurl/patches/patch-tests_json new file mode 100644 index 00000000000..961ef63cab4 --- /dev/null +++ b/net/trurl/patches/patch-tests_json @@ -0,0 +1,172 @@ +Handle uppercase URL escapes in tests, backport of +https://github.com/curl/trurl/commit/f22a2c45956f35702e437fb83ac05376f1956ec5 + +Index: tests.json +--- tests.json.orig ++++ tests.json +@@ -702,6 +702,7 @@ + "user=:hej:" + ] + }, ++ "excludes": ["uppercase-hex"], + "expected": { + "stdout": "https://%3ahej%3a@curl.se/hello\n", + "stderr": "", +@@ -2030,6 +2031,7 @@ + "localhost" + ] + }, ++ "excludes": ["uppercase-hex"], + "expected": { + "stdout": "/\\\\\n/%5c%5c\n", + "returncode": 0, +@@ -2045,6 +2047,7 @@ + "localhost" + ] + }, ++ "excludes": ["uppercase-hex"], + "expected": { + "stdout": [ + { +@@ -2071,6 +2074,7 @@ + "localhost" + ] + }, ++ "excludes": ["uppercase-hex"], + "expected": { + "stdout": "/%5c%5c\n/%5c%5c\n", + "returncode": 0, +@@ -2089,6 +2093,7 @@ + "localhost" + ] + }, ++ "excludes": ["uppercase-hex"], + "expected": { + "stdout": [ + { +@@ -3317,6 +3322,125 @@ + "expected": { + "stdout": "http://e/?e&a\n", + "returncode": 0 ++ } ++ }, ++ { ++ "input": { ++ "arguments": [ ++ "-s", ++ "path=\\\\", ++ "--json", ++ "localhost" ++ ] ++ }, ++ "required": ["uppercase-hex"], ++ "expected": { ++ "stdout": [ ++ { ++ "url": "http://localhost/%5C%5C", ++ "parts": { ++ "scheme": "http", ++ "host": "localhost", ++ "path": "/\\\\" ++ } ++ } ++ ], ++ "returncode": 0, ++ "stderr": "" ++ } ++ }, ++ { ++ "input": { ++ "arguments": [ ++ "-s", ++ "path=\\\\", ++ "-g", ++ "{path}\\n{:path}", ++ "--urlencode", ++ "localhost" ++ ] ++ }, ++ "required": ["uppercase-hex"], ++ "expected": { ++ "stdout": "/%5C%5C\n/%5C%5C\n", ++ "returncode": 0, ++ "stderr": "" ++ } ++ }, ++ { ++ "input": { ++ "arguments": [ ++ "-s", ++ "path=abc\\\\", ++ "-s", ++ "query:=a&b&a%26b", ++ "--urlencode", ++ "--json", ++ "localhost" ++ ] ++ }, ++ "required": ["uppercase-hex"], ++ "expected": { ++ "stdout": [ ++ { ++ "url": "http://localhost/abc%5C%5C?a&b&a%26b", ++ "parts": { ++ "scheme": "http", ++ "host": "localhost", ++ "path": "/abc%5C%5C", ++ "query": "a&b&a%26b" ++ }, ++ "params": [ ++ { ++ "key": "a", ++ "value": "" ++ }, ++ { ++ "key": "b", ++ "value": "" ++ }, ++ { ++ "key": "a&b", ++ "value": "" ++ } ++ ] ++ } ++ ], ++ "returncode": 0, ++ "stderr": "" ++ } ++ }, ++ { ++ "input": { ++ "arguments": [ ++ "--url", ++ "https://curl.se/hello", ++ "--set", ++ "user=:hej:" ++ ] ++ }, ++ "required": ["uppercase-hex"], ++ "expected": { ++ "stdout": "https://%3Ahej%3A@curl.se/hello\n", ++ "stderr": "", ++ "returncode": 0 ++ } ++ }, ++ { ++ "input": { ++ "arguments": [ ++ "-s", ++ "path=\\\\", ++ "-g", ++ "{path}\\n{:path}", ++ "localhost" ++ ] ++ }, ++ "required": ["uppercase-hex"], ++ "expected": { ++ "stdout": "/\\\\\n/%5C%5C\n", ++ "returncode": 0, ++ "stderr": "" + } + } + ] diff --git a/net/trurl/patches/patch-trurl_c b/net/trurl/patches/patch-trurl_c new file mode 100644 index 00000000000..be28883b061 --- /dev/null +++ b/net/trurl/patches/patch-trurl_c @@ -0,0 +1,15 @@ +Handle uppercase URL escapes in tests, backport of +https://github.com/curl/trurl/commit/f22a2c45956f35702e437fb83ac05376f1956ec5 + +Index: trurl.c +--- trurl.c.orig ++++ trurl.c +@@ -316,6 +316,8 @@ static void show_version(void) + #ifdef SUPPORTS_ZONEID + fprintf(stdout, " zone-id"); + #endif ++ if(data->version_num >= 0x080f00) ++ fprintf(stdout, " uppercase-hex"); + + fprintf(stdout, "\n"); + exit(0); diff --git a/net/trurl/pkg/DESCR b/net/trurl/pkg/DESCR new file mode 100644 index 00000000000..09e95566db5 --- /dev/null +++ b/net/trurl/pkg/DESCR @@ -0,0 +1,7 @@ +trurl is a tool in a similar spirit of tr but for URLs. Here, 'tr' stands for +translate or transpose. + +It is designed to help shell script authors everywhere. URLs are tricky to +parse and there are numerous security problems in software because of this. +trurl wants to help soften this problem by taking away the need for script and +command line authors everywhere to re-invent the wheel over and over. diff --git a/net/trurl/pkg/PLIST b/net/trurl/pkg/PLIST new file mode 100644 index 00000000000..bde0a12a578 --- /dev/null +++ b/net/trurl/pkg/PLIST @@ -0,0 +1,3 @@ +@bin bin/trurl +@man man/man1/trurl.1 +share/zsh/site-functions/_trurl