Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w3mman2html.cgi does not convert https to links #292

Open
cpaelzer opened this issue Jan 30, 2024 · 2 comments · May be fixed by #293
Open

w3mman2html.cgi does not convert https to links #292

cpaelzer opened this issue Jan 30, 2024 · 2 comments · May be fixed by #293

Comments

@cpaelzer
Copy link

Hi,
via a bug report on man page visualization I've realized that w3mman2html.cgi does not convert https to proper href links.

Reproducing the issue

$ cat > test << EOF
.TH TEST "1"
> .SH "Test"
> Test http URL: <http://www.gnu.org>
> .br
> Test https URL: <https://www.gnu.org>
> EOF

$ /usr/lib/w3m/cgi-bin/w3mman2html.cgi "local=/root/test"
Content-Type: text/html

<html>
<head><title>man </title></head>
<body>
<pre>
<u>TEST</u>(1)                                                                                     General Commands Manual                                                                                     <u>TEST</u>(1)

<b>Test</b>
       Test http URL: &lt;<a href="http://www.gnu.org">http://www.gnu.org</a>&gt;
       Test https URL: &lt;https://www.gnu.org&gt;

                                                                                                                                                                                                        <u><a href="file:///usr/lib/w3m/cgi-bin/w3mman2html.cgi?TEST(1)">TEST</a></u>(1)

You can see that the http link was converted to a proper link, while the https link was not changed.
I do not know if there is more to it as it seems to trivial and I feel I overlook something, but isn't that just this line:

s@(http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;

In my test I found this to work well

diff -Naur /usr/lib/w3m/cgi-bin/w3mman2html.cgi.orig /usr/lib/w3m/cgi-bin/w3mman2html.cgi.new 
--- /usr/lib/w3m/cgi-bin/w3mman2html.cgi.orig	2024-01-30 08:08:50.278360949 +0000
+++ /usr/lib/w3m/cgi-bin/w3mman2html.cgi.new	2024-01-30 08:15:19.521156596 +0000
@@ -162,7 +162,7 @@
     next;
   }
 
-  s@(http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;
+  s@(https|http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;
   s@\b(mailto:|)(\w[\w.\-]*\@\w[\w.\-]*\.[\w.\-]*\w)@<a href="mailto:$2">$1$2</a>@g;
   s@(\W)(\~?/[\w.][\w.\-/~]*)@$1 . &file_ref($2)@ge;
   s@(include(<\/?[bu]\>|\s)*\&lt;)([\w.\-/]+)@$1 . &include_ref($3)@ge;

I'll file this trivial change as a PR, but I can't get rid of the feeling that I'll be told why we can't make that change :-)

cpaelzer added a commit to cpaelzer/w3m that referenced this issue Jan 30, 2024
In addition to http|ftp do also convert https links to proper
links with a href statement.

Fixes: tats#292

Signed-off-by: Christian Ehrhardt <[email protected]>
@cpaelzer cpaelzer linked a pull request Jan 30, 2024 that will close this issue
@bptato
Copy link
Contributor

bptato commented Jan 30, 2024

I'll file this trivial change as a PR, but I can't get rid of the feeling that I'll be told why we can't make that change :-)

I've been using a very similar fix locally, and don't see why your patch wouldn't work :)

FWIW, another way I tried to fix this was to run MARK_URL through a W3m-Control header, but it seems there is no way to run the command after the page has been loaded :( So I guess the best solution is to adjust the regex as you did.

@rkta
Copy link
Contributor

rkta commented Jan 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants