Bug 401553 - Can't "View Document" with question mark in filename
Summary: Can't "View Document" with question mark in filename
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: General (show other bugs)
Version: 0.8.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-29 23:37 UTC by glyphimor
Modified: 2020-02-11 07:39 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.2
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description glyphimor 2018-11-29 23:37:05 UTC
SUMMARY

When you attempt to "View Document" for an entry with a localfile field containing a question mark ("?"), the file is not displayed. Instead, a "Choose Application" window pops up, asking you to "Select the program you want to use to open the file:" It then prints the filename, up to but not including the question mark.

Viewing the Source tab, the localfile field is being saved correctly (e.g. "localfile = {test?.txt}"). So presumably the "?" character just needs to be escaped on "View Document".

STEPS TO REPRODUCE

1. Create a new entry, or edit an existing one.
2. On the External tab, "Add file" and select a file with a "?" in it.
3. Save the entry and attempt to "View Document".

OBSERVED RESULT

Linked document file is not loaded; instead, a KDE "Choose Application" window pops up, listing an incorrect filename without an extension (i.e., the filename up to, but not including, the question mark).

EXPECTED RESULT

Linked document file is loaded by the appropriate program (KDE default).

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.50.0
KDE Frameworks Version: 5.50.0
Qt Version: 5.11.1

ADDITIONAL INFORMATION

There may be issues with other characters not being escaped correctly. For example, see bug 185433 in kframeworks-kio -- since 2009, all KDE Save As dialogs fail to escape double quotation marks. For example, entering the filename

a "test" file.txt

instead saves the file to

"test"

No other complaints. Thanks for the work on KBibTeX -- everything else works great.
Comment 1 glyphimor 2018-11-29 23:56:21 UTC
Thought I'd try linking a file w/ double quotes (e.g. a "test" file.pdf). The "Add file" dialog fails, like it would in any other KDE app. However, you can manually edit the filename in the External tab. Then it appears correctly in the localfile field on the Source tab.

After that, trying to View Document does open the correct document viewer (e.g. Okular for .pdf), but looks like the filename KDE/KBibTex sends to the document viewer is mangled. Error message in e.g. Okular is

Could not open file:///home/user/a %2522test%2522 file.pdf

Not sure what 2522 is... unicode 0x2522 is a random box-drawing char.
Comment 2 Christoph Feck 2018-12-03 21:32:59 UTC
%2522 is " percent-encoded twice.
Comment 3 Thomas Fischer 2018-12-06 21:01:52 UTC
(In reply to glyphimor from comment #0)
> SUMMARY
> 
> When you attempt to "View Document" for an entry with a localfile field
> containing a question mark ("?"), the file is not displayed. Instead, a
> "Choose Application" window pops up, asking you to "Select the program you
> want to use to open the file:" It then prints the filename, up to but not
> including the question mark.
> 
> Viewing the Source tab, the localfile field is being saved correctly (e.g.
> "localfile = {test?.txt}"). So presumably the "?" character just needs to be
> escaped on "View Document".

Please see the latest commit from branch 'bugs/kde401553' in my personal repository clone:
https://cgit.kde.org/clones/kbibtex/thomasfischer/kbibtex.git/log/?h=bugs/kde401553

This should fix the problem.

To test the code, please see here:
https://userbase.kde.org/KBibTeX/Development#Quick_Start_to_Run_KBibTeX_from_Git
but invoke the script as follows:
bash run-kbibtex.sh https://cgit.kde.org/clones/kbibtex/thomasfischer/kbibtex.git bugs/kde401553


> There may be issues with other characters not being escaped correctly. For
> example, see bug 185433 in kframeworks-kio -- since 2009, all KDE Save As
> dialogs fail to escape double quotation marks. For example, entering the
> filename
> 
> a "test" file.txt
> 
> instead saves the file to
> 
> "test"

I can confirm that this problem occurs in KBibTeX, too. So, waiting for an upstream fix ...

> No other complaints. Thanks for the work on KBibTeX -- everything else works
> great.
Nice to hear :-)
Comment 4 Thomas Fischer 2018-12-22 20:15:17 UTC
Have you been able to check branch 'bugs/kde401553' and can confirm if the bug has been fixed?
Comment 5 Bug Janitor Service 2019-01-06 03:44:15 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2019-01-21 04:33:11 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 7 Thomas Fischer 2020-02-11 07:28:02 UTC
Git commit 5ce346fe5518cd2835ed5315198adf85eef6734f by Thomas Fischer.
Committed on 10/02/2020 at 20:28.
Pushed by thomasfischer into branch 'kbibtex/0.10'.

View documents containing question mark characters

Construct a QUrl with the static method 'fromUserInput' to tolerate
characters like question marks as part of (local) file's name.

This commit is a manual forward-port of commit 0269321a6e3016305ba7
from branch 'kbibtex/0.9'.

M  +1    -0    ChangeLog
M  +3    -1    src/parts/part.cpp

https://commits.kde.org/kbibtex/5ce346fe5518cd2835ed5315198adf85eef6734f
Comment 8 Thomas Fischer 2020-02-11 07:28:28 UTC
Git commit 0269321a6e3016305ba7dd90bd377a04f1758101 by Thomas Fischer.
Committed on 10/02/2020 at 20:27.
Pushed by thomasfischer into branch 'kbibtex/0.9'.

View documents containing question mark characters

Construct a QUrl with the static method 'fromUserInput' to tolerate
characters like question marks as part of (local) file's name.
FIXED-IN: 0.9.2

M  +1    -0    ChangeLog
M  +3    -1    src/parts/part.cpp

https://commits.kde.org/kbibtex/0269321a6e3016305ba7dd90bd377a04f1758101
Comment 9 Thomas Fischer 2020-02-11 07:39:37 UTC
Git commit 2c85e816d7611de8802a020fbb60823407fad2c1 by Thomas Fischer.
Committed on 10/02/2020 at 20:29.
Pushed by thomasfischer into branch 'master'.

View documents containing question mark characters

Construct a QUrl with the static method 'fromUserInput' to tolerate
characters like question marks as part of (local) file's name.

This commit is a manual forward-port of commit 5ce346fe5518cd2835e
from branch 'master' which in its turn is a forward-port of commit
0269321a6e3016305ba7 from branch 'kbibtex/0.9'.

M  +1    -0    ChangeLog
M  +3    -1    src/parts/part.cpp

https://commits.kde.org/kbibtex/2c85e816d7611de8802a020fbb60823407fad2c1