commit trurl for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package trurl for openSUSE:Factory checked in at 2023-06-30 19:58:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/trurl (Old) and /work/SRC/openSUSE:Factory/.trurl.new.13546 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "trurl" Fri Jun 30 19:58:47 2023 rev:7 rq:1096031 version:0.8 Changes: -------- --- /work/SRC/openSUSE:Factory/trurl/trurl.changes 2023-06-14 16:31:09.703140299 +0200 +++ /work/SRC/openSUSE:Factory/.trurl.new.13546/trurl.changes 2023-06-30 19:59:06.485727638 +0200 @@ -1,0 +2,14 @@ +Sat Jun 17 12:01:48 UTC 2023 - Martin Hauke <mardnh@gmx.de> + +- Update to version 0.8 + Changes: + * add --urlencode + Bugfixes: + * --json/--get: .[].parts and {component} should be urldecoded + not encoded + * tests: use empty file instead of /dev/null + * typos in manpage + * Makefile: Allow CFLAGS to be appendable + * Makefile: be explicit in C standard to use + +------------------------------------------------------------------- Old: ---- trurl-0.7.tar.gz New: ---- trurl-0.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ trurl.spec ++++++ --- /var/tmp/diff_new_pack.Vts3kJ/_old 2023-06-30 19:59:07.413733158 +0200 +++ /var/tmp/diff_new_pack.Vts3kJ/_new 2023-06-30 19:59:07.457733420 +0200 @@ -18,7 +18,7 @@ Name: trurl -Version: 0.7 +Version: 0.8 Release: 0 Summary: Command line tool for URL parsing and manipulation License: MIT ++++++ trurl-0.7.tar.gz -> trurl-0.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/.github/workflows/codeql.yml new/trurl-trurl-0.8/.github/workflows/codeql.yml --- old/trurl-trurl-0.7/.github/workflows/codeql.yml 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/.github/workflows/codeql.yml 2023-06-17 12:52:17.000000000 +0200 @@ -13,11 +13,11 @@ on: push: - branches: [ "master" ] + branches: ["master"] pull_request: # The branches below must be a subset of the branches above - branches: [ "master" ] - + branches: ["master"] + jobs: analyze: name: Analyze @@ -30,27 +30,27 @@ strategy: fail-fast: false matrix: - language: [ 'cpp', 'python' ] + language: ['cpp', 'python'] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: install libcurl - run: | - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev - - - name: build - run: make - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: install libcurl + run: | + sudo apt-get update + sudo apt-get install libcurl4-openssl-dev + + - name: build + run: make + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/.github/workflows/codespell.yml new/trurl-trurl-0.8/.github/workflows/codespell.yml --- old/trurl-trurl-0.7/.github/workflows/codespell.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/trurl-trurl-0.8/.github/workflows/codespell.yml 2023-06-17 12:52:17.000000000 +0200 @@ -0,0 +1,16 @@ +name: "Codespell" +on: [push, pull_request] +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: install codespell + run: | + sudo apt-get update + sudo apt-get install codespell + + - name: Perform spelling checks + run: codespell README.md RELEASE-NOTES CONTRIBUTING.md trurl.1 trurl.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/.github/workflows/makefile.yml new/trurl-trurl-0.8/.github/workflows/makefile.yml --- old/trurl-trurl-0.7/.github/workflows/makefile.yml 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/.github/workflows/makefile.yml 2023-06-17 12:52:17.000000000 +0200 @@ -2,9 +2,9 @@ on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] jobs: ubuntu: @@ -13,36 +13,36 @@ strategy: matrix: build: - - name: default - install_packages: valgrind - test: test-memory - - name: clang sanitizers - install_packages: clang - test: test - make_opts: > - CC=clang - CFLAGS="-fsanitize=address,undefined,signed-integer-overflow -Wformat -Werror=format-security -Werror=array-bounds -g" - LDFLAGS="-fsanitize=address,undefined,signed-integer-overflow -g" + - name: default + install_packages: valgrind + test: test-memory + - name: clang sanitizers + install_packages: clang + test: test + make_opts: > + CC=clang + CFLAGS="-fsanitize=address,undefined,signed-integer-overflow -Wformat -Werror=format-security -Werror=array-bounds -g" + LDFLAGS="-fsanitize=address,undefined,signed-integer-overflow -g" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: install libcurl - run: | - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev ${{ matrix.build.install_packages }} + - name: install libcurl + run: | + sudo apt-get update + sudo apt-get install libcurl4-openssl-dev ${{ matrix.build.install_packages }} - - name: code style check - run: make checksrc + - name: code style check + run: make checksrc - - name: make - run: make ${{ matrix.build.make_opts }} + - name: make + run: make ${{ matrix.build.make_opts }} - - name: sanity test - run: ./trurl -v + - name: sanity test + run: ./trurl -v - - name: test - run: make ${{matrix.build.test}} + - name: test + run: make ${{matrix.build.test}} cygwin: runs-on: windows-latest @@ -70,11 +70,6 @@ steps: - uses: actions/checkout@v3 - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements.txt - - name: make run: make diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/CONTRIBUTING.md new/trurl-trurl-0.8/CONTRIBUTING.md --- old/trurl-trurl-0.7/CONTRIBUTING.md 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/CONTRIBUTING.md 2023-06-17 12:52:17.000000000 +0200 @@ -1,39 +1,39 @@ -# Contributing to trurl +# Contributing to trurl This document is intended to provide a framework for contributing to trurl. This document will go over requesting new features, fixing existing bugs and effectively -using the internal tooling to help PRs merge quickly. +using the internal tooling to help PRs merge quickly. ## Opening an issue -trurl uses GitHubs issue tracking to track upcoming work. If you have a feature you want to add or find a bug simply open an issue in the -[issues tab](https://github.com/curl/trurl/issues). Briefly describe the feature you are requesting and why you think it may be valuable for trurl. If you are -reporting a bug be prepared for questions as we will want to reproduce it locally. In general providing the output of `trurl --version` along with the operating -system / Distro you are running is a good starting point. +trurl uses GitHubs issue tracking to track upcoming work. If you have a feature you want to add or find a bug simply open an issue in the +[issues tab](https://github.com/curl/trurl/issues). Briefly describe the feature you are requesting and why you think it may be valuable for trurl. If you are +reporting a bug be prepared for questions as we will want to reproduce it locally. In general providing the output of `trurl --version` along with the operating +system / Distro you are running is a good starting point. ## Writing a good PR trurl is a relatively straightforward code base, so it is best to keep your PRs straightforward as well. Avoid trying to fix many bugs in one PR, and instead -use many smaller PRs as this avoids potential conflicts when merging. trurl is written in C and uses the [curl code style](https://curl.se/dev/code-style.html). -PRs that do not follow to code style will not be merged in. +use many smaller PRs as this avoids potential conflicts when merging. trurl is written in C and uses the [curl code style](https://curl.se/dev/code-style.html). +PRs that do not follow to code style will not be merged in. -trurl is in its early stages, so it's important to open a PR against a recent version of the source code, as a lot can change over a few days. -Preferably you would open a PR against the most recent commit in master. +trurl is in its early stages, so it's important to open a PR against a recent version of the source code, as a lot can change over a few days. +Preferably you would open a PR against the most recent commit in master. If you are implementing a new feature, it must be submitted with tests and documentation. The process for writing tests is explained below in the tooling section. Documentation exists -in two locations, the man page ([trurl.1](https://github.com/curl/trurl/blob/master/trurl.1)) and the help prompt when running `trurl -h`. Most documentation changes -will go in the man page, but if you add a new command line argument then it must be documented in the help page. +in two locations, the man page ([trurl.1](https://github.com/curl/trurl/blob/master/trurl.1)) and the help prompt when running `trurl -h`. Most documentation changes +will go in the man page, but if you add a new command line argument then it must be documented in the help page. -It is also important to be prepared for feedback on your PR and adjust it promptly. +It is also important to be prepared for feedback on your PR and adjust it promptly. ## Tooling -The trurl repository has a few small helper tools to make development easier. +The trurl repository has a few small helper tools to make development easier. -**checksrc.pl** is used to ensure the code style is correct. It accepts C files as command line arguments, and returns nothing if the code style is valid. If the +**checksrc.pl** is used to ensure the code style is correct. It accepts C files as command line arguments, and returns nothing if the code style is valid. If the code style is incorrect, checksrc.pl will provide the line the error is on and a brief description of what is wrong. You may run `make checksrc` to scan the entire -repository for style compliance. +repository for style compliance. -**test.py** is used to run automated tests for trurl. It loads in tests from `test.json` (described below) and reports the number of tests passed. You may specify +**test.py** is used to run automated tests for trurl. It loads in tests from `test.json` (described below) and reports the number of tests passed. You may specify the tests to run by passing a list of comma-separated numbers as command line arguments, such as `4,8,15,16,23,42` Note there is no space between the numbers. `test.py` may also use valgrind to test for memory errors by passing `--with-valgrind` as a command line argument, it should be noted that this may take a while to run all the tests. -`test.py` will also skip tests that require a specific curl runtime or buildtime. +`test.py` will also skip tests that require a specific curl runtime or buildtime. ### Adding tests tests are located in [tests.json](https://github.com/curl/trurl/blob/master/tests.json). This file is an array of json objects when outline an input and what the expected @@ -71,7 +71,7 @@ } } ``` -trurl may also return json. It you are adding a test that returns json to stdout, write the json directly instead of a string in the examples above. Below is an example +trurl may also return json. It you are adding a test that returns json to stdout, write the json directly instead of a string in the examples above. Below is an example of what stdout should be if it is a json test, where `"input"` is what trul accepts from the command line and `"expected"` is what trurl should return. ```json "expected": { @@ -93,6 +93,6 @@ ``` # Tips to make opening a PR easier -- Run `make checksrc` and `make test-memory` locally before opening a PR. These ran automatically when a PR is opened so you might as well make sure they pass before-hand. +- Run `make checksrc` and `make test-memory` locally before opening a PR. These ran automatically when a PR is opened so you might as well make sure they pass before-hand. - Update the man page and the help prompt accordingly. Documentation is annoying but if everyone writes a little it's not bad. - Add tests to cover new features or the bug you fixed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/Makefile new/trurl-trurl-0.8/Makefile --- old/trurl-trurl-0.7/Makefile 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/Makefile 2023-06-17 12:52:17.000000000 +0200 @@ -1,7 +1,7 @@ TARGET = trurl OBJS = trurl.o LDLIBS = $$(curl-config --libs) -CFLAGS = $$(curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g +CFLAGS += $$(curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g -std=gnu99 MANUAL = trurl.1 PREFIX ?= /usr/local diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/RELEASE-NOTES new/trurl-trurl-0.8/RELEASE-NOTES --- old/trurl-trurl-0.7/RELEASE-NOTES 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/RELEASE-NOTES 2023-06-17 12:52:17.000000000 +0200 @@ -1,27 +1,18 @@ -trurl 0.7 +trurl 0.8 Changes since previous release - o --default-port to ask for the default to be used if not present - o --keep-port to ask for the port number to be there even if default - o --no-guess-scheme option to disable scheme guessing - o --punycode to ask for the punycode version in output + o add --urlencode Bugfixes since previous release - o --help returns 0 instead of 1 - o --json: print empty arrays - o --redirect: don't silently ignore failed redirections. - o makefile: use -Wshadow and -Werror by default - o makefile: Use DESTDIR only during install target - o refuse setting same component in --set as --iterate - o restructure the JSON output object - o send -h output to stdout, not stderr - o trurl.1: add an example using --iterate - o trurl.1: document the JSON output format - o use curl_url_cleanup() insted of curl_free() + o --json/--get: .[].parts and {component} should be urldecoded not encoded + o tests: use empty file instead of /dev/null + o typos in manpage + o Makefile: Allow CFLAGS to be appendable + o Makefile: be explicit in C standard to use Contributors to this release: - Daniel Stenberg, Ehsan, Emanuele Torre, Enno Tensing, Gustavo Costa, - Jacob Mealey, Michael Ablassmeier, Renato Botelho + Daniel Stenberg, Emanuele Torre, Krishean Draconis, Michael Ablassmeier, + Paul Wise, Sevan Janiyan diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/checksrc.pl new/trurl-trurl-0.8/checksrc.pl --- old/trurl-trurl-0.7/checksrc.pl 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/checksrc.pl 2023-06-17 12:52:17.000000000 +0200 @@ -98,13 +98,13 @@ ); sub readskiplist { - open(W, "<$dir/checksrc.skip") or return; - my @all=<W>; + open(my $W, '<', "$dir/checksrc.skip") or return; + my @all=<$W>; for(@all) { $windows_os ? $_ =~ s/\r?\n$// : chomp; $skiplist{$_}=1; } - close(W); + close($W); } # Reads the .checksrc in $dir for any extended warnings to enable locally. @@ -380,7 +380,7 @@ my $l = ""; my $prep = 0; my $prevp = 0; - open(R, "<$file") || die "failed to open $file"; + open(my $R, '<', $file) || die "failed to open $file"; my $incomment=0; my @copyright=(); @@ -388,7 +388,7 @@ checksrc_clear(); # for file based ignores accept_violations(); - while(<R>) { + while(<$R>) { $windows_os ? $_ =~ s/\r?\n$// : chomp; my $l = $_; my $ol = $l; # keep the unmodified line for error reporting @@ -531,7 +531,7 @@ } elsif(($first eq "*") && ($word !~ /(for|if|while|switch)/)) { # A "(*" beginning makes the space OK because it wants to - # allow funcion pointer declared + # allow function pointer declared } elsif($1 =~ / *typedef/) { # typedefs can use space-paren @@ -883,7 +883,7 @@ checkwarn("COPYRIGHT", 1, 0, $file, "", "Missing copyright statement", 1); } - # COPYRIGHTYEAR is a extended warning so we must first see if it has been + # COPYRIGHTYEAR is an extended warning so we must first see if it has been # enabled in .checksrc if(defined($warnings{"COPYRIGHTYEAR"})) { # The check for updated copyrightyear is overly complicated in order to @@ -933,7 +933,7 @@ checksrc_endoffile($file); - close(R); + close($R); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/requirements.txt new/trurl-trurl-0.8/requirements.txt --- old/trurl-trurl-0.7/requirements.txt 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/requirements.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -packaging==23.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/test.py new/trurl-trurl-0.8/test.py --- old/trurl-trurl-0.7/test.py 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/test.py 2023-06-17 12:52:17.000000000 +0200 @@ -2,7 +2,6 @@ import sys from os import getcwd, path -import re import json import shlex from subprocess import PIPE, run @@ -63,7 +62,7 @@ ) if isinstance(self.expected["stdout"], list): - # if we dont expect string, parse to json + # if we don't expect string, parse to json try: stdout = json.loads(output.stdout) except json.decoder.JSONDecodeError: @@ -78,7 +77,8 @@ return True def test(self): - # return true only if stdout, stderr and errorcode is equal to the ones found in testfile + # return true only if stdout, stderr and errorcode + # are equal to the ones found in the testfile self.testPassed = all( testComponent(asdict(self.commandOutput)[k], exp) for k, exp in self.expected.items()) @@ -127,7 +127,7 @@ baseCmd += ".exe" # check if the trurl executable exists if path.isfile(baseCmd): - # get the run-time and build-time libcurl versions + # get the version info for the feature list output = run( [baseCmd, "--version"], stdout=PIPE, stderr=PIPE, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/tests.json new/trurl-trurl-0.8/tests.json --- old/trurl-trurl-0.7/tests.json 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/tests.json 2023-06-17 12:52:17.000000000 +0200 @@ -1285,7 +1285,7 @@ "scheme": "https", "host": "example.com", "path": "/", - "query": "utm=tra%20cker&address%20=home&here=now&thisthen" + "query": "utm=tra cker&address =home&here=now&thisthen" }, "params": [ { @@ -1656,7 +1656,7 @@ { "input": { "arguments": [ - "imaps://user:pasword;crazy@[ff00::1234%hello]:1234/path?a=b&c=d#fragment", + "imaps://user:password;crazy@[ff00::1234%hello]:1234/path?a=b&c=d#fragment", "--json" ] }, @@ -1664,11 +1664,11 @@ "returncode": 0, "stdout": [ { - "url": "imaps://user:pasword;crazy@[ff00::1234%25hello]:1234/path?a=b&c=d#fragment", + "url": "imaps://user:password;crazy@[ff00::1234%25hello]:1234/path?a=b&c=d#fragment", "parts": { "scheme": "imaps", "user": "user", - "password": "pasword", + "password": "password", "options": "crazy", "host": "[ff00::1234]", "port": "1234", @@ -1809,7 +1809,7 @@ "input": { "arguments": [ "-f", - "/dev/null", + "testfiles/test0002.txt", "--json" ] }, @@ -1834,5 +1834,152 @@ "returncode": 0, "stderr": "" } + }, + { + "input": { + "arguments": [ + "-s", + "path=\\\\", + "-g", + "{path}\\n{:path}", + "localhost" + ] + }, + "expected": { + "stdout": "/\\\\\n/%5c%5c\n", + "returncode": 0, + "stderr": "" + } + }, + { + "input": { + "arguments": [ + "-s", + "path=\\\\", + "--json", + "localhost" + ] + }, + "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" + ] + }, + "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" + ] + }, + "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": [ + "-s", + "scheme:=http", + "-s", + "host:=localhost", + "-s", + "path:=/ABC%5C%5C", + "-s", + "query:=a&b&a%26b" + ] + }, + "expected": { + "stdout": "http://localhost/ABC%5c%5c?a&b&a%26b\n", + "returncode": 0, + "stderr": "" + } + }, + { + "input": { + "arguments": [ + "-g", + "{query:b}\\t{query-all:a}\\n{:query:b}\\t{:query-all:a}", + "https://example.org/foo?a=1&b=%23&a=%26#hello" + ] + }, + "expected": { + "stdout": "#\t1 &\n%23\t1 %26\n", + "returncode": 0, + "stderr": "" + } + }, + { + "input": { + "arguments": [ + "--urlencode", + "-g", + "{query:b}\\t{query-all:a}\\n{:query:b}\\t{:query-all:a}", + "https://example.org/foo?a=1&b=%23&a=%26#hello" + ] + }, + "expected": { + "stdout": "%23\t1 %26\n%23\t1 %26\n", + "returncode": 0, + "stderr": "" + } } ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/trurl.1 new/trurl-trurl-0.8/trurl.1 --- old/trurl-trurl-0.7/trurl.1 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/trurl.1 2023-06-17 12:52:17.000000000 +0200 @@ -95,7 +95,7 @@ the scheme's default port will be output if it is known. If \fBpuny:\fP is specified, like "{puny:url}" or "{puny:host}", the -"punycoded" version of the host name will be used in the ouptut. +"punycoded" version of the host name will be used in the output. If \fI--default-port\fP is specified, all formats are expanded as if they used \fIdefault:\fP; and if \fI--punycode\fP is used, all formats @@ -146,7 +146,7 @@ component names. See below for details on the format. .IP "--keep-port" By default, trurl removes default port numbers from URLs with a known scheme -even if they are explictly specified in the input URL. This options, makes +even if they are explicitly specified in the input URL. This options, makes trurl not remove them. .IP "--no-guess-scheme" Disables libcurl's scheme guessing feature. URLs that do not contain a scheme @@ -193,6 +193,9 @@ If the URL cannot be parsed for whatever reason, trurl will simply move on to the next provided URL - unless \fI--verify\fP is used. +.IP "--urlencode" +Outputs URL encoded version of components by default when using \fI--get\fP or +\fI--json\fP. .IP "--trim [component]=[what]" Trims data off a component. Currently this can only trim a query component. @@ -216,27 +219,28 @@ .IP "parts" This key exists in every object, and contains an object with a key for each of the settable URL components. If a component is missing, it means -it is not present in the URL. +it is not present in the URL. The parts are URL decoded unless \fI--urlencode\fP +is used. .RS .TP .B "scheme" The URL scheme. .TP .B "user" -The URL decoded user name. +The user name. .TP .B "password" -The URL decoded password. +The password. .TP .B "options" -The URL decoded options. Note that only a few URL schemes support the -"options" component. +The options. Note that only a few URL schemes support the "options" +component. .TP .B "host" -The URL decoded and normalized host name. It might be a UTF-8 name if an IDN -name was used. It can also be a normalized IPv4 or IPv6 address. An IPv6 address -always starts with a bracket (\fB[\fP) - and no other host names can contain -such a symbol. +The and normalized host name. It might be a UTF-8 name if an IDN name was used. +It can also be a normalized IPv4 or IPv6 address. An IPv6 address always starts +with a bracket (\fB[\fP) - and no other host names can contain such a symbol. If +\fI--punycode\fP is used, the punycode version of the host is outputted instead. .TP .B "port" The provided port number as a string. If the port number was not provided in the @@ -244,13 +248,13 @@ default port for that scheme will be provided here. .TP .B "path" -The URL decoded path. Including the leading slash. +The path. Including the leading slash. .TP .B "query" -The URL decoded full query, excluding the question mark separator. +The full query, excluding the question mark separator. .TP .B "fragment" -The URL decoded fragment, excluding the pound sign separator. +The fragment, excluding the pound sign separator. .TP .B "zoneid" The zone id, which can only be present in an IPv6 address. When this key is diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/trurl.c new/trurl-trurl-0.8/trurl.c --- old/trurl-trurl-0.7/trurl.c 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/trurl.c 2023-06-17 12:52:17.000000000 +0200 @@ -77,7 +77,7 @@ #define REPLACE_NULL_BYTE '.' /* for query:key extractions */ enum { - VARMODIFIER_URLDECODED = 1 << 1, + VARMODIFIER_URLENCODED = 1 << 1, VARMODIFIER_DEFAULT = 1 << 2, VARMODIFIER_PUNY = 1 << 3, }; @@ -182,6 +182,7 @@ " --sort-query - alpha-sort the query pairs\n" " --trim [component]=[what] - trim component\n" " --url [URL] - URL to work with\n" + " --urlencode - URL encode components by default\n" " -v, --version - show version\n" " --verify - return error on (first) bad URL\n" " URL COMPONENTS:\n" @@ -255,8 +256,8 @@ bool punycode; bool sort_query; bool no_guess_scheme; + bool urlencode; bool end_of_options; - unsigned char output; /* -- stats -- */ unsigned int urls; @@ -473,6 +474,8 @@ op->no_guess_scheme = true; else if(!strcmp("--sort-query", flag)) op->sort_query = true; + else if(!strcmp("--urlencode", flag)) + op->urlencode = true; else return 1; /* unrecognized option */ return 0; @@ -523,8 +526,9 @@ CURLU_PUNYCODE : 0)| #endif CURLU_NON_SUPPORT_SCHEME| - ((modifiers & VARMODIFIER_URLDECODED) ? - CURLU_URLDECODE : 0)); + (((modifiers & VARMODIFIER_URLENCODED) || + o->urlencode) ? + 0 :CURLU_URLDECODE)); } static void showurl(FILE *stream, struct option *o, int modifiers, @@ -569,6 +573,7 @@ char *cl; size_t vlen; bool isquery = false; + bool queryall = false; int mods = 0; end = strchr(ptr, endbyte); ptr++; /* pass the { */ @@ -580,7 +585,7 @@ /* {path} {:path} */ if(*ptr == ':') { - mods |= VARMODIFIER_URLDECODED; + mods |= VARMODIFIER_URLENCODED; ptr++; } vlen = end - ptr; @@ -597,29 +602,28 @@ else { /* {query: or {query-all: */ if(!strncmp(ptr, "query-all:", cl - ptr + 1)) { - showqkey(stream, cl + 1, end - cl - 1, - (mods & VARMODIFIER_URLDECODED) == 0, true); - } - else if(!strncmp(ptr, "query:", cl - ptr + 1)) { isquery = true; - showqkey(stream, cl + 1, end - cl - 1, - (mods & VARMODIFIER_URLDECODED) == 0, false); + queryall = true; } + else if(!strncmp(ptr, "query:", cl - ptr + 1)) + isquery = true; else { /* syntax error */ vlen = 0; end[1] = '\0'; - break; } - isquery = true; + break; } ptr = cl + 1; vlen = end - ptr; } while(true); - if(isquery) - ; + if(isquery) { + showqkey(stream, cl + 1, end - cl - 1, + !op->urlencode && !(mods & VARMODIFIER_URLENCODED), + queryall); + } else if(!vlen) errorf(ERROR_GET, "Bad --get syntax: %s", start); else if(!strncmp(ptr, "url", vlen)) @@ -728,8 +732,8 @@ unsigned int mask = 0; for(node = o->set_list; node; node = node->next) { const struct var *v; - char *set = node->data; - v = setone(uh, set); + char *setline = node->data; + v = setone(uh, setline); if(v) { if(mask & (1 << v->part)) errorf(ERROR_SET, "duplicate --set for component %s", v->name); @@ -994,17 +998,15 @@ static void qpair2query(CURLU *uh, struct option *o) { int i; - int rc; char *nq = NULL; - char *oldnq; for(i = 0; i<nqpairs; i++) { - oldnq = nq; + char *oldnq = nq; nq = curl_maprintf("%s%s%s", nq?nq:"", (nq && *nq && *qpairs[i])? o->qsep: "", qpairs[i]); curl_free(oldnq); } if(nq) { - rc = curl_url_set(uh, CURLUPART_QUERY, nq, 0); + int rc = curl_url_set(uh, CURLUPART_QUERY, nq, 0); if(rc) warnf("internal problem"); } @@ -1067,7 +1069,6 @@ } } do { - char iterbuf[1024]; struct curl_slist *p; bool url_is_invalid = false; unsigned setmask = 0; @@ -1076,6 +1077,7 @@ setmask = set(uh, o); if(iter) { + char iterbuf[1024]; /* "part=item1 item2 item2" */ const char *part; size_t plen; @@ -1129,7 +1131,7 @@ urlencode ? "" : ":", (int)wlen, w); setone(uh, iterbuf); - if(iter && iter->next) { + if(iter->next) { struct iterinfo info; memset(&info, 0, sizeof(info)); info.uh = uh; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trurl-trurl-0.7/version.h new/trurl-trurl-0.8/version.h --- old/trurl-trurl-0.7/version.h 2023-05-29 10:31:11.000000000 +0200 +++ new/trurl-trurl-0.8/version.h 2023-06-17 12:52:17.000000000 +0200 @@ -22,6 +22,6 @@ * ***************************************************************************/ -#define TRURL_VERSION_TXT "0.7" +#define TRURL_VERSION_TXT "0.8" #endif
participants (1)
-
Source-Sync