// validate extension in targetResource
if (!S_ISREG(statBuff.st_mode)) // if directory: no check
return ;
lastDotPos = this->targetResource.rfind('.');
lastSlashPos = this->targetResource.rfind('/');
// check if the last dot exists and comes after the last slash (if any)
if (lastDotPos != std::string::npos && (lastSlashPos == std::string::npos || lastDotPos > lastSlashPos))
extension = this->targetResource.substr(lastDotPos + 1);
// check if extension in the set for the given content-type key
it = mimeTypesDict.find(contentTypeValue);
if (!extension.empty())
{ // if file: check extension against map
if (it->second.find(extension) != it->second.end()) // if in map, return to continue
return ;
} // if file with no extension: no check - hence no code for else
}
if (!extension.empty()) // if no content and extension: 422
this->response.updateStatus(422, "Unprocessable Content");
If we ever need this, as @loudapet said