Package: urlview
Version: 0.9-21+b1
Severity: normal
Tags: patch

Dear Maintainer,

I ~often receive URLs that end in a fancy quote (or close enough);
this can be reproduced with
  echo https://example.com/a” | urlview
which displays
  UrlView 0.9: (1 matches) Press Q or Ctrl-C to Quit!

  ->    1 https://example.com/a�~@~]

I've narrowed it down to being linked to narrow-character ncurses(??)
and am attaching a patch (based on current Salsa) and have opened
  https://salsa.debian.org/debian/urlview/-/merge_requests/3

Best,
наб

-- System Information:
Debian Release: 11.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-16-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, 
TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages urlview depends on:
ii  libc6           2.31-13+deb11u3
ii  libncurses6     6.2+20201114-2
ii  libtinfo6       6.2+20201114-2
ii  sensible-utils  0.0.14

Versions of packages urlview recommends:
ii  lynx [www-browser]  2.9.0dev.6-3~deb11u1
ii  w3m [www-browser]   0.5.3+git20210102-6

Versions of packages urlview suggests:
pn  mutt          <none>
pn  ncftp | lftp  <none>
ii  wget          1.21-1+deb11u1

-- no debconf information
From 957868f8722c76907840c214d83fca3c86971c9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Wed, 17 Aug 2022 22:26:27 +0200
Subject: [PATCH 1/2] d/control: depend on libcurses-dev directly
X-Mutt-PGP: OS

libncurses5-dev is a "transitional package for libncurses-dev"
---
 debian/changelog | 3 ++-
 debian/control   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0292d4f..9d83027 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,9 @@ urlview (0.9-23) UNRELEASED; urgency=medium
   * d/url_handler: don't require bash for no reason, shellcheck-clean
   * d/README.Debian: align with reality w.r.t. url_handler.sh
     Closes: #1017562
+  * d/control: depend on libcurses-dev directly
 
- -- наб <nabijaczlew...@nabijaczleweli.xyz>  Wed, 17 Aug 2022 21:42:22 +0200
+ -- наб <nabijaczlew...@nabijaczleweli.xyz>  Wed, 17 Aug 2022 22:28:38 +0200
 
 urlview (0.9-22) unstable; urgency=medium
 
diff --git a/debian/control b/debian/control
index 527952d..e7384b5 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,7 @@ Maintainer: Emanuele Rocca <e...@debian.org>
 Standards-Version: 4.2.0
 Vcs-Browser: https://salsa.debian.org/debian/urlview
 Vcs-Git: https://salsa.debian.org/debian/urlview.git
-Build-Depends: libncurses5-dev, debhelper (>= 13)
+Build-Depends: libncurses-dev, debhelper (>= 13)
 
 Package: urlview
 Architecture: any
-- 
2.30.2

From 6a2f08ab28343e8c5b7c7ab4a64f09beb913fd91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Wed, 17 Aug 2022 22:33:38 +0200
Subject: [PATCH 2/2] Link against libncursesw, setlocale(LC_ALL, "")
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Mutt-PGP: OS

On https://example.com/a” (i.e. a fancy quote), urlview with
narrow-character curses makes an absolute hash of it, by writing it as:
  https://example.com/a�~@~]

When linked against the wide-character ncurses, it displays it exactly
as expected, in the original form.
---
 configure.in     | 2 +-
 debian/changelog | 3 ++-
 urlview.c        | 3 +++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index 45e4e89..7bbd68e 100644
--- a/configure.in
+++ b/configure.in
@@ -24,7 +24,7 @@ AC_ARG_WITH(slang, [  --with-slang[=DIR]      use S-Lang instead of curses],
 		LIBS="$LIBS -lslang -lm"
 	fi],
 
-	[AC_CHECK_LIB(ncurses, initscr, [LIBS="$LIBS -lncurses"], [LIBS="$LIBS -lcurses"])
+	[AC_CHECK_LIB(ncursesw, initscr, [LIBS="$LIBS -lncursesw"], [LIBS="$LIBS -lcurses"])
 	AC_CHECK_FUNCS(curs_set)
 	AC_CHECK_HEADERS(ncurses.h)
 	AC_CHECK_HEADER(ncurses/curses.h, [CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"])])
diff --git a/debian/changelog b/debian/changelog
index 9d83027..ffe47ea 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,8 +4,9 @@ urlview (0.9-23) UNRELEASED; urgency=medium
   * d/README.Debian: align with reality w.r.t. url_handler.sh
     Closes: #1017562
   * d/control: depend on libcurses-dev directly
+  * Link against libncursesw, fixing display of non-ASCII URLs
 
- -- наб <nabijaczlew...@nabijaczleweli.xyz>  Wed, 17 Aug 2022 22:28:38 +0200
+ -- наб <nabijaczlew...@nabijaczleweli.xyz>  Wed, 17 Aug 2022 22:39:23 +0200
 
 urlview (0.9-22) unstable; urgency=medium
 
diff --git a/urlview.c b/urlview.c
index 9281bbb..7b28408 100644
--- a/urlview.c
+++ b/urlview.c
@@ -32,6 +32,7 @@
 #endif /* USE_SLANG */
 
 #include <pwd.h>
+#include <locale.h>
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -144,6 +145,8 @@ void search_backward (char *search, int urlcount, char **url, int *redraw, int *
  
 int main (int argc, char **argv)
 {
+  setlocale(LC_ALL, "");
+
   struct passwd *pw;
   struct stat stat_buf;
 #ifndef USE_SLANG
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature

Reply via email to