|
|
d3752c |
diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc
|
|
|
d3752c |
index da9867f..e992638 100644
|
|
|
d3752c |
--- a/src/clients/FtpGateway.cc
|
|
|
d3752c |
+++ b/src/clients/FtpGateway.cc
|
|
|
d3752c |
@@ -1084,16 +1084,17 @@ Ftp::Gateway::checkAuth(const HttpHeader * req_hdr)
|
|
|
d3752c |
void
|
|
|
d3752c |
Ftp::Gateway::checkUrlpath()
|
|
|
d3752c |
{
|
|
|
d3752c |
- static SBuf str_type_eq("type=");
|
|
|
d3752c |
- auto t = request->url.path().rfind(';');
|
|
|
d3752c |
-
|
|
|
d3752c |
- if (t != SBuf::npos) {
|
|
|
d3752c |
- auto filenameEnd = t-1;
|
|
|
d3752c |
- if (request->url.path().substr(++t).cmp(str_type_eq, str_type_eq.length()) == 0) {
|
|
|
d3752c |
- t += str_type_eq.length();
|
|
|
d3752c |
- typecode = (char)xtoupper(request->url.path()[t]);
|
|
|
d3752c |
- request->url.path(request->url.path().substr(0,filenameEnd));
|
|
|
d3752c |
- }
|
|
|
d3752c |
+ // If typecode was specified, extract it and leave just the filename in
|
|
|
d3752c |
+ // url.path. Tolerate trailing garbage or missing typecode value. Roughly:
|
|
|
d3752c |
+ // [filename] ;type=[typecode char] [trailing garbage]
|
|
|
d3752c |
+ static const SBuf middle(";type=");
|
|
|
d3752c |
+ const auto typeSpecStart = request->url.path().find(middle);
|
|
|
d3752c |
+ if (typeSpecStart != SBuf::npos) {
|
|
|
d3752c |
+ const auto fullPath = request->url.path();
|
|
|
d3752c |
+ const auto typecodePos = typeSpecStart + middle.length();
|
|
|
d3752c |
+ typecode = (typecodePos < fullPath.length()) ?
|
|
|
d3752c |
+ static_cast<char>(xtoupper(fullPath[typecodePos])) : '\0';
|
|
|
d3752c |
+ request->url.path(fullPath.substr(0, typeSpecStart));
|
|
|
d3752c |
}
|
|
|
d3752c |
|
|
|
d3752c |
int l = request->url.path().length();
|