diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-03-16 11:42:14 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-03-16 11:44:05 +0100 |
commit | 77c01f6caa7cd6709d8323e760896f16b37a3fd5 (patch) | |
tree | 41f482bb9bb57e47c5570f0bd9e0b5a03333f126 /man.filter.dpi | |
parent | 384339108b4b55fd43ad605da0aaea0f3f207053 (diff) |
Allow fragments in man: URLs
When linking to an specific section of a manual by using the #<frag>
fragment, we need to remove it before passing it to man(1), otherwise it
will be interpreted as part of the manual page name.
Diffstat (limited to 'man.filter.dpi')
-rwxr-xr-x | man.filter.dpi | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/man.filter.dpi b/man.filter.dpi index 5b9adbc..afe880e 100755 --- a/man.filter.dpi +++ b/man.filter.dpi @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2023 Rodrigo Arias Mallo +# Copyright (c) 2023-2025 Rodrigo Arias Mallo # SPDX-License-Identifier: GPL-3.0-or-later IFS= read -d '>' auth # Ignore auth @@ -53,15 +53,17 @@ fix_br() { serve_manpage() { url="$1" ref="${url#"man:"}" + # Remove #<frag> fragment if any + cleanref=$(echo "$ref" | sed 's/#.*$//') # Reverse open(3) -> 3 open if given - manpage=$(echo "$ref" | sed 's/\(.*\)(\(.*\))/\2 \1/') + manpage=$(echo "$cleanref" | sed 's/\(.*\)(\(.*\))/\2 \1/') # If page not found, return 404 if [ -z "$manpage" ]; then serve_404 exit 0 fi if ! man -w $manpage 2>/dev/null; then - apropos=$(echo "$ref" | sed 's/(.*)//') + apropos=$(echo "$cleanref" | sed 's/(.*)//') serve_404 "$manpage" "$apropos" else printf "<cmd='start_send_page' url='' '>\n" |