Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to local file with spaces in name does not work on Linux with Gio #548

Closed
gkatev opened this issue Feb 26, 2021 · 4 comments
Closed

Comments

@gkatev
Copy link

gkatev commented Feb 26, 2021

Hi,
I'm having trouble working with links to local files which contain spaces in their names.

In this markdown:

[file](file.txt)
[file with spaces](file with spaces.txt)

The first link works, while the seconds one outputs an error: (both files exist)

gio: file:///home/gkatev/Desktop/file%2520with%2520spaces.txt: Error when getting information for file “/home/gkatev/Desktop/file%20with%20spaces.txt”: No such file or directory

Might it be a problem in Retext?
I initially thought it to be a python-qt or gnome-gio error, so I reported it here: (apparently mistakenly so!)
https://bugreports.qt.io/browse/PYSIDE-1488

I think the relevant code is the QDesktopServices.openUrl() call at preview.py:49?
In the report, it was suggested that QUrl.fromLocalFile() or QUrl.fromUserInput() should be used instead. (?)

Can you reproduce this issue?
I am on Arch Linux, with Cinnamon as the DE.

@gkatev gkatev changed the title Link to local file with spaces in name does not work, on Linux with Gio Link to local file with spaces in name does not work on Linux with Gio Feb 26, 2021
@mitya57
Copy link
Member

mitya57 commented Feb 27, 2021

Fixed in master, can you please test?

@gkatev
Copy link
Author

gkatev commented Feb 27, 2021

Hm, I'm still getting an error, but a slightly different one. The file it's trying to open contains even more escape codes:

gio: file:///home/gkatev/Desktop/file%255C%2520with%255C%2520spaces.txt: Error when getting information for file “/home/gkatev/Desktop/file%5C%20with%5C%20spaces.txt”: No such file or directory

@mitya57 mitya57 reopened this Feb 27, 2021
@mitya57
Copy link
Member

mitya57 commented Feb 27, 2021

Wow, that string in your example is triply percent encoded!

However I cannot reproduce it. Does your Markdown source still contain [file with spaces](file with spaces.txt)? Or it is already percent-encoded in Markdown source?

Can you please add some debug prints around this line:

link = QUrl.fromLocalFile(fileToOpen)

and print: the initial value of link, the value of fileToOpen, and the value of link after that line?

@gkatev
Copy link
Author

gkatev commented Feb 27, 2021

Ok ok my bad, I had added some back-slashes in the file name in the MD while testing, and forgot about them!
All works correctly now, thanks

@gkatev gkatev closed this as completed Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants