mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
add checking for leading slash in mapping operations
This commit is contained in:
parent
6f044e1cd3
commit
672f8ec1f7
1 changed files with 14 additions and 0 deletions
|
@ -244,6 +244,7 @@ void AssetServer::handleGetAllMappingOperation(ReceivedMessage& message, SharedN
|
|||
void AssetServer::handleSetMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket) {
|
||||
if (senderNode->getCanRez()) {
|
||||
QString assetPath = message.readString();
|
||||
|
||||
auto assetHash = message.read(SHA256_HASH_LENGTH).toHex();
|
||||
|
||||
if (setMapping(assetPath, assetHash)) {
|
||||
|
@ -511,6 +512,12 @@ bool AssetServer::writeMappingsToFile() {
|
|||
}
|
||||
|
||||
bool AssetServer::setMapping(const AssetPath& path, const AssetHash& hash) {
|
||||
|
||||
if (path[0] != '/') {
|
||||
qWarning() << "Cannot set a mapping that does not have a leading forward slash:" << path;
|
||||
return false;
|
||||
}
|
||||
|
||||
// remember what the old mapping was in case persistence fails
|
||||
auto oldMapping = _fileMappings.value(path).toString();
|
||||
|
||||
|
@ -593,6 +600,13 @@ bool AssetServer::deleteMappings(const AssetPathList& paths) {
|
|||
}
|
||||
|
||||
bool AssetServer::renameMapping(const AssetPath& oldPath, const AssetPath& newPath) {
|
||||
if (oldPath[0] != '/' || newPath[0] != '/') {
|
||||
qWarning() << "Cannot perform rename with invalid paths - both should have leading forward slashes:"
|
||||
<< oldPath << "=>" << newPath;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// figure out if this rename is for a file or folder
|
||||
if (pathIsFolder(oldPath)) {
|
||||
if (!pathIsFolder(newPath)) {
|
||||
|
|
Loading…
Reference in a new issue