View Single Post
Old 08-25-2024, 10:24 AM   #64
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,860
Karma: 6120478
Join Date: Nov 2009
Device: many
Yes the detection of illegal characters in new file names does not come until quite late in the bulk rename process to better accommodate RegexRename which can generate many different filename pieces derived from the original.

I will duplicate the forbidden character check and add it much earlier in the rename template code and abort out of all renames if any part of the "template" has or uses forbidden characters.

Thanks for your bug report!

Update: I decided it would be best to check the user supplied rename template for forbidden characters and abort the entire rename if there are any issues by adding this routine in RenameSelect() in BookBrowser.cpp:

Code:
    if (!template_name.isEmpty()) {
        // Verify the template name does not have any forbidden chars in the name                                                       
        const QString badchars = "<>:\"/\\|?*";
        bool has_bad_chars = false;
        foreach(QChar ch, template_name) {
            has_bad_chars = has_bad_chars || badchars.contains(ch);
        }
        if (has_bad_chars) {
            Utility::DisplayStdErrorDialog(tr("Filenames can not contain these characters: \"%1\".").arg(badchars));
            return;
        }
    }
That seems to have done the trick for the case you reported. I have now pushed this to master.

Last edited by KevinH; 08-25-2024 at 10:58 AM.
KevinH is offline   Reply With Quote