Bug 418758 - Okular will not open file if "#" is in the filename or file path when "Open with" method is used.
Summary: Okular will not open file if "#" is in the filename or file path when "Open w...
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 1.9.2
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 422856 432023 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-03-12 00:54 UTC by Richard Ferguson
Modified: 2022-01-21 18:18 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
attachment-8302-0.html (2.29 KB, text/html)
2020-06-26 23:14 UTC, Richard Ferguson
Details
attachment-31156-0.html (1.81 KB, text/html)
2022-01-21 16:53 UTC, Richard Ferguson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Ferguson 2020-03-12 00:54:40 UTC
SUMMARY
Okular will not open file if "#" is in the filename or file path when "Open with" method is used.  Okular will open files which have "#" in filename or file path when the Open command in the menu is used.

STEPS TO REPRODUCE
1. Select a PDF file that opens in Okular.
2. Rename file by inserting a "#" anywhere in its file name.
3. Right click on file, select "Open with", select Okular.
4. Okular fails to open file and reports an "Error - Okular ? Could not open file:...".  Note filename truncates at "#".
5. Create folder which has "#" in its name.
6. Rename PDF file by removing "#" from filename.
7. Move renamed file to newly created folder (has "#" in its name).
8. Right click on file, select "Open with", select Okular.
9. Okular fails to open file and reports an "Error - Okular ? Could not open file:...". Note path name truncates at "#".


OBSERVED RESULT
Okular fails to open file which has a "#" in its filename or file path.

EXPECTED RESULT
Okular should open file which has a "#" in its filename or file path.

SOFTWARE/OS VERSIONS
Windows: Windows 10 build 1909
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Okular will open files with "#" in filename or "#" in file path if Open menu command is used.
Comment 1 David Hurka 2020-06-26 21:10:07 UTC
*** Bug 422856 has been marked as a duplicate of this bug. ***
Comment 2 David Hurka 2020-06-26 21:15:18 UTC
If the document URL contains a #, Okular tries to focus the page specified by the number following the #. Of course this fails if # is part of the actual URL.

It was already suggested to interpret only #page=1234 as page number command, currently Okular expects #1234 which doesn’t match the behavior of other applications.

There is another older bug report about the original issue in this bug report, but I don’t find it right now.
Comment 3 Jack 2020-06-26 22:59:28 UTC
(reposting from one of the duplicate bugs)  I just tested on (Gentoo) Linux, okular 1.9.3 (I see 1.10 is out) and it works fine.  I also tested 1.9.2 (latest available in the Windows Store) in a Wind 10 guest in VirtualBox, and it also works fine whether # is at the beginning or in the middle of the file name.  What version of Windows are you on?

Might the behavior depend on whether what is after the # are just digits, or non-digit alpha characters.
Comment 4 Richard Ferguson 2020-06-26 23:14:14 UTC
Created attachment 129709 [details]
attachment-8302-0.html

OS Name    Microsoft Windows 10 Home
Version    10.0.18363 Build 18363

Okular version 1.9.2.

It does not matter whether the characters following the "#" are blank,
numbers or letters.  As soon as Okular parses to the "#" it stops parsing
and because the file name is incomplete, the file cannot be opened.

On Fri, Jun 26, 2020 at 3:59 PM Jack <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=418758
>
> Jack <ostroffjh@users.sourceforge.net> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|
> |ostroffjh@users.sourceforge
>                    |                            |.net
>
> --- Comment #3 from Jack <ostroffjh@users.sourceforge.net> ---
> (reposting from one of the duplicate bugs)  I just tested on (Gentoo)
> Linux,
> okular 1.9.3 (I see 1.10 is out) and it works fine.  I also tested 1.9.2
> (latest available in the Windows Store) in a Wind 10 guest in VirtualBox,
> and
> it also works fine whether # is at the beginning or in the middle of the
> file
> name.  What version of Windows are you on?
>
> Might the behavior depend on whether what is after the # are just digits,
> or
> non-digit alpha characters.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 5 Jack 2020-06-26 23:40:55 UTC
Have you diagnosed what is happening in a debugger, or are you assuming?  In my case, on both Windows and Linux, it is able to open a file with # in the name, using the File/Open dialog, or when launced by command line. so there is likely something different between our systems.  What locale (country/language) are you using?  I have en_US.UTF-8, although I have no idea if it matters.

(Note that when replying by email, you can remove what you are replying to, as it is already posted to the bug.)
Comment 6 Sergei K 2020-06-27 07:52:36 UTC
I also have similar problem that reported in bug 423490. Appears only if you click on a document in Explorer or use "Open with". From cli doesn't work the same way. Opening from the Okular menu works correctly.
Comment 7 Jack 2020-06-28 17:23:57 UTC
I can now confirm this.  I'll guess it has something to do with how Windows Explorer passes the file name to Okular, and how Okular then processes it.  If I have two pdf files name "test#test.pdf" and "test" (no extension) and try to open the first - it does open the second.  This supports the idea that the file name Okular tries to open gets truncated at the first #.  Opening from Explorer with Edge works.

Opening on Linux with Dolphin does work; I haven't tried other linux file managers.
Comment 8 David Hurka 2020-06-29 06:15:43 UTC
Maybe Explorer passes the # as #, and Dolphin passes it as %35?

Code is here:
https://invent.kde.org/graphics/okular/-/blob/master/part.cpp#L1736
Comment 9 Jack 2020-07-07 00:02:05 UTC
I haven't had time to try anything on Windows yet, but by creating a shell script called okular, and placing it earlier in my path, and invoking it by clicking on the file in Dolphin, it seems to not encode the # in any way in the invokation.  (I just had the script pass $@ through "od -c" and append it to a file.)  What I'm not sure of is whether okular then tries to open that as a file or URL.
Comment 10 Yuri Chornoivan 2021-01-24 07:59:23 UTC
*** Bug 432023 has been marked as a duplicate of this bug. ***
Comment 11 Albert Astals Cid 2022-01-21 14:31:15 UTC
Have you tried with a newer Okular version?

At least this works fine for me on Windows11 https://imgur.com/a/Q9WjB8i (sorry for the potato quality video)
Comment 12 Richard Ferguson 2022-01-21 16:53:06 UTC
Created attachment 145721 [details]
attachment-31156-0.html

The bug is fixed and the issue is resolved.

Thank you very much.

On Fri, Jan 21, 2022 at 6:31 AM Albert Astals Cid <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=418758
>
> Albert Astals Cid <aacid@kde.org> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>          Resolution|---                         |WAITINGFORINFO
>              Status|REPORTED                    |NEEDSINFO
>                  CC|                            |aacid@kde.org
>
> --- Comment #11 from Albert Astals Cid <aacid@kde.org> ---
> Have you tried with a newer Okular version?
>
> At least this works fine for me on Windows11 https://imgur.com/a/Q9WjB8i
> (sorry
> for the potato quality video)
>
> --
> You are receiving this mail because:
> You reported the bug.