MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / extractSafeFilePath

Method extractSafeFilePath

Libraries/Http/HttpAsyncFileServer.cpp:482–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480 return "application/octet-stream";
481}
482
483Result HttpAsyncFileServer::Internal::extractSafeFilePath(StringSpan requestTarget, StringSpan& filePath)
484{
485 HttpRequestTargetView target;
486 SC_TRY(target.parse(requestTarget));
487 if (not HttpStringIterator::startsWith(target.path, "/"))
488 return Result::Error(HttpResultCategory, HttpError::FileServerRequestTargetNotPath);
489
490 filePath = HttpStringIterator::sliceStart(target.path, 1);
491 if (filePath.isEmpty())
492 {
493 filePath = "index.html";
494 return Result(true);
495 }
496
497 return validateSafeRelativePath(filePath);
498}
499

Callers

nothing calls this directly

Calls 4

sliceStartFunction · 0.85
ResultClass · 0.50
parseMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected