PDF files cannot be opened when directory path contains "&"

*** Please report new bugs here! ***

Moderators: xnview, Dreamer

adelphos
Posts: 1
Joined: Thu Oct 29, 2026 9:15 pm

PDF files cannot be opened when directory path contains "&"

Post by adelphos »

Hello Pierre,

I found a reproducible bug in XnView MP on Linux when opening PDF files with Ghostscript.

System:

OS: LMDE 7 (Debian 13), x86_64
XnView MP: installed in /opt/XnView/
Ghostscript: 10.05.1
Ghostscript library: libgs.so.10

Problem:

XnView MP fails to open a PDF file when its directory path contains an ampersand (&). The application displays an error message indicating that the file cannot be opened.

When I copy the same PDF to a directory without an ampersand, XnView opens it successfully.

Steps to reproduce:

Create a directory e.g. named:

Code: Select all

Test&Test
my filename was:

Code: Select all

/mnt/hdd_h/Temp/Test&Test/Test.pdf
Copy any valid PDF file into that directory.
Try to open the PDF with XnView MP.
XnView displays an error.
Move the same PDF to a directory without & and try again.
=> The PDF opens correctly.

When starting XnView MP from a terminal, I get the following terminal messages:

Code: Select all

0.38.0 (git b43ab43) - Multimedia Development Kit. Copyright (c) 2016-2026 WangBin(QtAV author) <wbsecg1 at gmail.com>
Build for: linuxmint/7 6.12.113+deb13-amd64 4KB x86_64; glibc2.24/2.41 libc++240000; Clang24.0.0 (++20260810082117+1069de7c5ab7-1~exp1~20260810202127.1778); 01:36:54 Aug 11 2026. 
==> 1,000000  1,000000  92,607288  96,000000  (0)
XNVIEW restoreGeometry before : 640 480 
XNVIEW restoreGeometry after : 1536 864 
ARG[] = /opt/XnView/XnView
qt.qpa.services: Failed to register with host portal QDBusError("org.freedesktop.portal.Error.Failed", "Could not register app ID: Connection already associated with an application ID")
BLOB length 75 
## updateCount ===>   0ms (6)
## updateCount ===>   0ms (10)
## updateCount ===>   0ms (1)
## updateCount ===>   0ms 
## updateCount ===>   0ms ok
dataChanged() called with an invalid index range:
    topleft: QModelIndex(-1,-1,0x0,QObject(0x0))
    bottomRight:QModelIndex(-1,-1,0x0,QObject(0x0))
sh: 1: Test/Test.pdf: not found
Error: /undefinedfilename in (/mnt/hdd_h/Temp/Test)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:755/1123(ro)(G)--   --dict:0/20(G)--   --dict:85/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 10.05.1: Unrecoverable error, exit code 1
Unrecoverable error: rangecheck in .putdeviceprops
Analysis:

It appears that XnView MP invokes Ghostscript through a shell without properly quoting or escaping the PDF filename.
The shell interprets the & character as a command separator/background operator, splitting the path into separate commands.
Ghostscript itself works correctly when invoked manually with the full filename enclosed in quotation marks.

Expected behavior:

PDF files should open regardless of special characters such as & in their directory paths or filenames.

Suggested fix:
Properly quote or escape file paths when invoking Ghostscript, or preferably invoke the external process with a separate argument vector rather than constructing a shell command string.

Could you please check this?

Best regards
Adelphos