![]() |
#1 |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 437
Karma: 145424
Join Date: Dec 2017
Device: Kobo
|
Move file : invalide folder path
I wanted to move some files into a folder and since I'm under windows, I used the anti-slash '\' >> "Error, invalid path" >> replaced it by '/' >> OK
Ah, a little parse/replace is missing ![]() |
![]() |
![]() |
![]() |
#2 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5703082
Join Date: Nov 2009
Device: many
|
All epub paths are bookpaths from the epub root so these should only use "/" as all hrefs do on all platforms.
Checked the actual code and I am happy that it handles things and only lets valid bookpaths through and \ is not a valid url or href character so I think the code does what it needs to here: Code:
SelectFolder select_folder(group, m_Book, this); // Get the destination folder from the user if (select_folder.exec() != QDialog::Accepted) { return; } QString folder_path = select_folder.GetFolder(); // Make sure folder_path is valid if abort bool valid_path = folder_path.indexOf("..") == -1; valid_path = valid_path && folder_path.indexOf("\\") == -1; valid_path = valid_path && !folder_path.startsWith("/"); valid_path = valid_path && !folder_path.startsWith("./"); valid_path = valid_path && !folder_path.startsWith("."); valid_path = valid_path && folder_path.indexOf("/.") == -1; valid_path = valid_path && !folder_path.startsWith("META-INF"); valid_path = valid_path && folder_path.indexOf("META-INF") == -1; if (!valid_path) { Utility::DisplayStdErrorDialog( tr("Destination Folder has invalid path \"%1\"").arg(folder_path)); return; } Last edited by KevinH; 12-27-2020 at 10:56 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 437
Karma: 145424
Join Date: Dec 2017
Device: Kobo
|
Ok, this is an invalid character, but as is the folder separation character in Windows, applying a simple replace '\' to '/' before testing and moving, could be handy.
That's what I meant. I know that Windows is inferior in this usage, but since it is a folder/file path, most programs (see languages) consider both characters as equivalent, probably thanks to a small and discreet character replacement. This is not the case with Sigil, which is "too" strict. |
![]() |
![]() |
![]() |
#4 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5703082
Join Date: Nov 2009
Device: many
|
Yes, we could do that to help some users who are not distinguishing internal epub paths from external OS file paths.
But then I would worry that those same people may start using the wrong folder separator in hrefs and src attributes and epub root relative paths throughout css, opf, xhtml, ncx, etc. Also because BookBrowser is not meant to be a FileBrowser that change may confuse things even more. So Sigil when dealing with paths internal to the epub tries to uniformly use the forward slash just like Qt and Python in this regard. At least that was the design idea. Yes, it should be an easy change to make, I am just not sure it is for the best. But I am no Windows user, so perhaps others will weigh in on if this will serve to just confuse users or not. |
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,680
Karma: 23983815
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Code:
cd c:/Windows Code:
cd c:\Windows 3. Users should never have to manually enter paths, since Sigil will automatically suggest the right location(s), when users click the Folders drop-down button. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I'm in favor of leaving it the way it is. The tooltip path shows the forward slash. Book Browser shows the forward slash (if the preference to show the full bookpath is turned on). And the Move dialog itself shows the forward slash whenever selecting existing folders to move resources to. Changing it just to let Windows users continue to make the same mistake over and over (with no notice) makes little sense to me. Make the mistake once, learn what's expected and move on. It's a non-issue in my opinion.
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
4) Users seeking to alter the internal structure of an epub are unlikely to be tripped up by the forward slash url-path requirement.
|
![]() |
![]() |
![]() |
#8 | |
Chalut o/
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 437
Karma: 145424
Join Date: Dec 2017
Device: Kobo
|
Quote:
Why is it a mistake to use the default folder separator of your operating system ??? I'm not talking about how it was saved or displayed, just the tolerance of Input Text. Just the Input Text, what happens behind it, I don't care. If making a simple "Replace character" (one, has a specific use and in a single window) for a little interpolarity is too complicated: OK, I'm out. Enjoy your world as a minority Linuxian. |
|
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,680
Karma: 23983815
Join Date: Dec 2010
Device: Kindle PW2
|
|
![]() |
![]() |
![]() |
#10 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Do browsers automatically fix urls for Windows users who use backslashes instead of forward ones? Does Sigil fix any other hrefs where a user mistakenly uses back slashes? The paths to files in epubs are hrefs, not os-specific paths.
Quote:
As to your ridiculous insinuation that I would ever limit myself to a single operating system: enjoy your naivete. |
|
![]() |
![]() |
![]() |
#11 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 110
Karma: 1133068
Join Date: Sep 2007
Device: ipaq
|
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Well would you look at that?
![]() I'm still not really in favor of Sigil doing it. But if someone were to submit a pull request that doesn't break anything else, I'm sure Kevin and I would at least consider incorporating it. I'm just not going to take time to code it up. |
![]() |
![]() |
![]() |
#13 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,611
Karma: 29710338
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
I often type "http:\\whatever/comes/next.com", current browsers (including firefox) etc don't seem to mind, but it does bother people if I type them like that in a message, email etc .
It makes me wonder if there was a time when URIs did use '\\' after the protocol name. Why is the '//' there anyway, is the ':' not enough of a delimiter? BR |
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
I'm pretty sure that back-slashes where never valid in URI's. But, the URI sort of looks like a file path and that's what Windows uses for the separator, so...
And apparently, the "//" indicates the start of the "authority component". Or at least it does according to the Wikipedia article: https://en.wikipedia.org/wiki/Unifor...rce_Identifier |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to set content-server [path to library folder...] on Win 10 | sh1cpan | Server | 3 | 08-06-2020 05:09 PM |
Sigil temporary files folder default path | dlibke | Sigil | 13 | 06-06-2019 04:28 AM |
updating folder/file path on device | sbergstc | Calibre Companion | 3 | 09-06-2016 06:37 PM |
I have a question about the end of folder path,help! | Jerome0840 | Library Management | 11 | 03-23-2013 10:48 AM |
Move ebooks to folder | helsan | Library Management | 2 | 02-23-2013 08:34 PM |