From 6797037028ea83717cfc7619d32f005371fd8e37 Mon Sep 17 00:00:00 2001 From: Tina_Azure <-> Date: Mon, 11 Sep 2023 14:46:18 +0200 Subject: [PATCH] File Submission Blacklisted Character config Default characters are chosen to avoid potential issues within the URI and FS --- spec/spec.md | 2 ++ src/default-cavecomm.conf | 5 +++++ src/utilities.cpp | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/spec/spec.md b/spec/spec.md index e3da1ad..12e6770 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -267,4 +267,6 @@ optional:{default} submissionAllowedFiletypes={rar|zip|7z} Allowed file extensions like rar|zip|7z|webm|avi etc; submissionMaxFileNameSize={255} 12 characters are used for hash, How big a file name can be the default persumes the NAME_MAX length within common file systems submissionMaxFilePathSize={4096} How big a file path can be the default persumes the PATH_MAX length within common file systems + submissionBlacklistedCharacters={#|%|&|{|}|\|<|>|*|?|/|$|!|'|"|:|@|+|`|=|\|} #default blacklist of characters that may cause issues can be overwritten, For "|" and "=" write it as "OR" and "EQUAL" since the config splits by | and = + diff --git a/src/default-cavecomm.conf b/src/default-cavecomm.conf index de9f83d..810d993 100644 --- a/src/default-cavecomm.conf +++ b/src/default-cavecomm.conf @@ -29,6 +29,10 @@ # submissionAllowedFiletypes={rar|zip|7z} # Allowed file extensions like rar|zip|7z|webm|avi etc; # submissionMaxFileNameSize={255} # 12 characters are used for hash, How big a file name can be the default persumes the NAME_MAX length within common file systems # submissionMaxFilePathSize={4096} # How big a file path can be the default persumes the PATH_MAX length within common file systems +# submissionBlacklistedCharacters={#|%|&|{|}|\|<|>|*|?|/|$|!|'|"|:|@|+|`|=|\|} #default blacklist of characters that may cause issues can be overwritten, For "|" and "=" write it as "OR" and "EQUAL" since the config splits by | and = + + + @@ -61,5 +65,6 @@ submissionMaxStorageDurationH=24; submissionAllowedFiletypes=rar|zip|7z|arc|jpg|jpeg|png|mp4|webm; submissionMaxFileNameSize=255; submissionMaxFilePathSize=4096; +submissionBlacklistedCharacters=#|%|&|{|}|\|<|>|*|?|/|$|!|'|"|:|@|+|`|EQUAL|OR; #configend# diff --git a/src/utilities.cpp b/src/utilities.cpp index ed4f692..46de979 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -161,6 +161,7 @@ namespace Utilities { int submissionMaxFileNameSize = 255; int submissionMaxFilePathSize = 4096; int baseDirectoryPathSize = 0; + std::vector submissionBlacklistedCharacters = {"#","%","&","{","}","\\","<",">","*","?","/","$","!","'","\"",":","@","+","`","=","|"}; /* * calculates absolute file path length based on submission directory and current path @@ -330,6 +331,18 @@ namespace Utilities { submissionMaxFilePathSize = std::stoi(lineString); continue; } + if (lineVector.at(0) == "submissionBlacklistedCharacters") { + submissionBlacklistedCharacters = Utilities::splitStringIntoVector(lineString, '|'); + if (lineString.find("EQUAL") != std::string::npos || lineString.find("OR") != std::string::npos) { + for (std::string& submissionBlacklistedCharacter : submissionBlacklistedCharacters) { + if (submissionBlacklistedCharacter == "EQUAL") + submissionBlacklistedCharacter = "="; + if (submissionBlacklistedCharacter == "OR") + submissionBlacklistedCharacter = "|"; + } + } + continue; + } } } }