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}
481
482Result HttpAsyncFileServer::Internal::extractSafeFilePath(StringSpan requestTarget, StringSpan& filePath)
483{
484 HttpRequestTargetView target;
485 SC_TRY(target.parse(requestTarget));
486 SC_TRY_MSG(HttpStringIterator::startsWith(target.path, "/"), "HttpAsyncFileServer request target must be path");
487
488 filePath = HttpStringIterator::sliceStart(target.path, 1);
489 if (filePath.isEmpty())
490 {
491 filePath = "index.html";
492 return Result(true);
493 }
494
495 return validateSafeRelativePath(filePath);
496}
497
498Result HttpAsyncFileServer::Internal::normalizeOptionFilePath(StringSpan filePath, StringSpan& normalizedPath)
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