diff --git a/ChangeLog b/ChangeLog index b1b0a3f0..e22be60a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-14 Tatsuhiro Tsujikawa + + Made keyName static const. Made trimmed charset static const + std::string. + * src/Util.cc (getContentDispositionFilename) + 2008-05-14 Tatsuhiro Tsujikawa Made USER_AGENT const. Made "/" static const std::string. diff --git a/src/Util.cc b/src/Util.cc index acf8349d..937986f2 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -513,12 +513,12 @@ IntSequence Util::parseIntRange(const std::string& src) } std::string Util::getContentDispositionFilename(const std::string& header) { - std::string keyName = "filename="; + static const std::string keyName = "filename="; std::string::size_type attributesp = header.find(keyName); if(attributesp == std::string::npos) { return A2STR::NIL; } - std::string::size_type filenamesp = attributesp+strlen(keyName.c_str()); + std::string::size_type filenamesp = attributesp+keyName.size(); std::string::size_type filenameep; if(filenamesp == header.size()) { return A2STR::NIL; @@ -533,7 +533,8 @@ std::string Util::getContentDispositionFilename(const std::string& header) { if(filenameep == std::string::npos) { filenameep = header.size(); } - return trim(header.substr(filenamesp, filenameep-filenamesp), "\r\n '\""); + static const std::string TRIMMED("\r\n '\""); + return trim(header.substr(filenamesp, filenameep-filenamesp), TRIMMED); } static int nbits[] = {