Bug 495839 - Cannot open file in path like "D:\#Temp\#Share\test.pdf"
Summary: Cannot open file in path like "D:\#Temp\#Share\test.pdf"
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (other bugs)
Version First Reported In: 23.08.1
Platform: Microsoft Windows Microsoft Windows
: HI normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 421421 428323 461705 501793 502133 502512 504681 514827 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-11-05 13:34 UTC by xlleon
Modified: 2026-02-09 16:26 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
reproduce step 1 (18.10 KB, image/png)
2024-11-22 07:15 UTC, xlleon
Details
reproduce step 2 (1.88 MB, image/png)
2024-11-22 07:16 UTC, xlleon
Details
reproduce step 3 (795.45 KB, image/png)
2024-11-22 07:17 UTC, xlleon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description xlleon 2024-11-05 13:34:17 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
When open a pdf file "D:\#Temp\#Share\test.pdf", it does not open the file. Instead, it opens the folder "D:\#Temp\"

STEPS TO REPRODUCE
- Same as summary

OBSERVED RESULT
- Same as summary

EXPECTED RESULT
- Same as summary

SOFTWARE/OS VERSIONS
Windows: 

ADDITIONAL INFORMATION
Comment 1 Will Sierzputowski 2024-11-21 18:57:19 UTC
Thank you for reporting, but this is unclear and there is not enough information to try to replicate this behavior. 

Can you describe how you are trying to open this file (file->open, is okualr registered to open PDFs through windows, etc). You say that it opens a folder. What opens a folder? Is okular somehow displaying the directory, or is windows explorer opening a view at the location? Are you able to open the PDF in question if it is in a different location, like your Desktop?
Comment 2 xlleon 2024-11-22 07:15:21 UTC
It is easy to reproduce:
1. Create a folder with "#" in its name, put a pdf file and two image files in it. From example, I have D:\#test\ folder, 1 pdf and 2 pictures in it (attached 1.png).
2. Open the pdf file with okular, I use "open with" from windows right click pop-up menu.
3. Okular does not open the pdf, but show the 2 picture file (attached 2.png). 
4. You can the open history from attached 3.png
Comment 3 xlleon 2024-11-22 07:15:59 UTC
Created attachment 176032 [details]
reproduce step 1
Comment 4 xlleon 2024-11-22 07:16:36 UTC
Created attachment 176033 [details]
reproduce step 2
Comment 5 xlleon 2024-11-22 07:17:00 UTC
Created attachment 176034 [details]
reproduce step 3
Comment 6 Will Sierzputowski 2024-11-22 14:06:05 UTC
Thanks for the steps. I can duplicate this behavior on Windows 11 (Okular 24.11.80). 

I will have to look more into what could cause this, but here is a summary of what I tested.

- I can only cause this behavior when the file is opened through Windows explorer with 'Right Click->Open With->Okular'. It does not happen when the file is opened from inside of Okular(File->open) and does not happen when the file is opened by dragging the PDF into an already running Okular instance. A short-term solution would be opening the file in one of these other ways.

- If only happens when the folder has a ‘#’ in the first position, or when ‘.#’ are the first two positions. Names such as 't#est\test.pdf' work correctly. 

- This happens when opened from the commands line too ‘okular.exe test.pdf’ if the above regarding ‘#’ is true about the file directory. This also happens when the file is hard linked i.e. ‘okular.exe D:\#test\test.pdf’. 

- The same behavior occurs if Okular is invoked with path to the directory the PDF file is in. ‘okular.exe D:\#test’. This works with out without # and I believe is intended behavior

My tentative conclusion is this is an issue with parsing the command line parameter (Windows invokes the call for ‘open with’ through command line parameters) which causes the PDF file to be ignored when the directory starts with #. When I look more into it, I will see if the issue Windows only or also persists on a Linux system.
Comment 7 John Kizer 2025-04-07 18:21:27 UTC
*** Bug 501793 has been marked as a duplicate of this bug. ***
Comment 8 John Kizer 2025-04-07 18:22:14 UTC
*** Bug 461705 has been marked as a duplicate of this bug. ***
Comment 9 John Kizer 2025-04-12 19:20:11 UTC
*** Bug 502512 has been marked as a duplicate of this bug. ***
Comment 10 John Kizer 2025-05-27 04:15:54 UTC
*** Bug 502133 has been marked as a duplicate of this bug. ***
Comment 11 John Kizer 2025-05-27 04:16:33 UTC
*** Bug 504681 has been marked as a duplicate of this bug. ***
Comment 12 aristsakas 2026-02-08 12:40:40 UTC
this bug was first reported in bug 421421 4 years ago. Since this bug report more complete and investigated i make this the master bug
Comment 13 aristsakas 2026-02-08 12:40:56 UTC
*** Bug 421421 has been marked as a duplicate of this bug. ***
Comment 14 aristsakas 2026-02-08 12:41:05 UTC
*** Bug 428323 has been marked as a duplicate of this bug. ***
Comment 15 aristsakas 2026-02-08 12:41:13 UTC
*** Bug 514827 has been marked as a duplicate of this bug. ***
Comment 16 Bug Janitor Service 2026-02-08 15:41:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/1315
Comment 17 Christoph Cullmann 2026-02-09 16:26:59 UTC
Git commit 523397d2864e11c5c5854cd8dce0b8ab1dad352c by Christoph Cullmann.
Committed on 09/02/2026 at 16:16.
Pushed by cullmann into branch 'master'.

fix file exists check

we need to pass QFile::exists what toLocalFile does,
not just path

that should work on all platforms, like Windows

M  +1    -1    shell/shellutils.cpp

https://invent.kde.org/graphics/okular/-/commit/523397d2864e11c5c5854cd8dce0b8ab1dad352c