SyncEngine: For server older than 8.1, ignore invalid char in new directories

Server older than 8.1 cannot cope with invalid char in the filename
so we must not send them from the client. We were already checking
for new files, but not for renames or new directories.

https://github.com/owncloud/enterprise/issues/1009
This commit is contained in:
Olivier Goffart 2016-01-13 17:49:41 +01:00
parent a18b13d56e
commit bbedeed1c5
2 changed files with 13 additions and 10 deletions

View file

@ -199,16 +199,6 @@ void PropagateUploadFileQNAM::start()
return;
}
if (_propagator->account()->serverVersionInt() < 0x080100) {
// Server version older than 8.1 don't support these character in filename.
static const QRegExp invalidCharRx("[\\\\:?*\"<>|]");
if (_item->_file.contains(invalidCharRx)) {
_item->_httpErrorCode = 400; // So the entry get blacklisted
done(SyncFileItem::NormalError, tr("File name contains at least one invalid character"));
return;
}
}
_propagator->_activeJobs++;
if (!_deleteExisting) {

View file

@ -816,6 +816,19 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
(*it)->_file = adjustRenamedPath((*it)->_file);
}
// Check for invalid character in old server version
if (_account->serverVersionInt() < 0x080100) {
// Server version older than 8.1 don't support these character in filename.
static const QRegExp invalidCharRx("[\\\\:?*\"<>|]");
for (auto it = _syncedItems.begin(); it != _syncedItems.end(); ++it) {
if ((*it)->_direction == SyncFileItem::Up &&
(*it)->destination().contains(invalidCharRx)) {
(*it)->_errorString = tr("File name contains at least one invalid character");
(*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
}
}
}
// Sort items per destination
std::sort(_syncedItems.begin(), _syncedItems.end());