mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
extended character filtering to fit a common denominator for all filesystems
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5979 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
892057b53e
commit
bb7645549f
@ -1061,14 +1061,15 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
|
||||
QString cleanname = link.name() ;
|
||||
bool bad_chars = false ;
|
||||
static const QString bad_chars_str = "/\\\"*:?<>|" ;
|
||||
|
||||
for(uint32_t i=0;i<cleanname.length();++i)
|
||||
if(cleanname[i] == '/' || cleanname[i] == '\\')
|
||||
{
|
||||
cleanname[i] = '_';
|
||||
flag |= RSLINK_PROCESS_NOTIFY_BAD_CHARS ;
|
||||
}
|
||||
for(uint32_t j=0;j<bad_chars_str.length();++j)
|
||||
if(cleanname[i] == bad_chars_str[j])
|
||||
{
|
||||
cleanname[i] = '_';
|
||||
flag |= RSLINK_PROCESS_NOTIFY_BAD_CHARS ;
|
||||
}
|
||||
|
||||
if (rsFiles->FileRequest(cleanname.toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
|
||||
fileAdded.append(link.name());
|
||||
@ -1348,7 +1349,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
}
|
||||
if(flag & RSLINK_PROCESS_NOTIFY_BAD_CHARS)
|
||||
result += QString("<br>%1").arg(QObject::tr("Warning: '/' and '\\' characters in some of the\nabove filenames will be replaced by '_'.")) ;
|
||||
result += QString("<br>%1").arg(QObject::tr("Warning: forbidden characters found in filenames. \nCharacters <b>\",|,/,\\,<,>,*,?</b> will be replaced by '_'.")) ;
|
||||
|
||||
if (result.isEmpty() == false) {
|
||||
QMessageBox mb(QObject::tr("Result"), "<html><body>" + result + "</body></html>", QMessageBox::Information, QMessageBox::Ok, 0, 0);
|
||||
|
@ -97,7 +97,7 @@ RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const s
|
||||
_fileEntriesTW->installEventFilter(this);
|
||||
|
||||
if(wrong_chars)
|
||||
QMessageBox::warning(NULL,tr("Bad filenames have been cleaned"),tr("Some filenames or directory names in this collection file\ncontained '/' or '\\' characters. They have been substitued to '_',\nand are listed in red.")) ;
|
||||
QMessageBox::warning(NULL,tr("Bad filenames have been cleaned"),tr("Some filenames or directory names contained forbidden characters.\nCharacters <b>\",|,/,\\,<,>,*,?</b> will be replaced by '_'.\n Concerned files are listed in red.")) ;
|
||||
}
|
||||
|
||||
bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
|
@ -59,15 +59,17 @@ void RsCollectionFile::downloadFiles() const
|
||||
|
||||
static QString purifyFileName(const QString& input,bool& bad)
|
||||
{
|
||||
static const QString bad_chars = "/\\\"*:?<>|" ;
|
||||
bad = false ;
|
||||
QString output = input ;
|
||||
|
||||
for(uint32_t i=0;i<output.length();++i)
|
||||
if(output[i] == '/' || output[i] == '\\')
|
||||
{
|
||||
output[i] = '_' ;
|
||||
bad = true ;
|
||||
}
|
||||
for(int j=0;j<bad_chars.length();++j)
|
||||
if(output[i] == bad_chars[j])
|
||||
{
|
||||
output[i] = '_' ;
|
||||
bad = true ;
|
||||
}
|
||||
|
||||
return output ;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user