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