Made word/parameter constructor with 'string' explicit to avoid implicit use of default charset.

This commit is contained in:
Vincent Richard 2015-02-17 22:12:20 +01:00
parent 50b1dfcb05
commit 52e5d74bec
5 changed files with 47 additions and 7 deletions

View File

@ -639,7 +639,7 @@ static void connectStore()
: std::string(path.begin() + s, path.begin() + p); : std::string(path.begin() + s, path.begin() + p);
if (!x.empty()) if (!x.empty())
newFolder = newFolder->getFolder(x); newFolder = newFolder->getFolder(vmime::utility::path::component(x));
if (p == std::string::npos) if (p == std::string::npos)
break; break;

View File

@ -44,7 +44,7 @@ private:
public: public:
parameter(const string& name); explicit parameter(const string& name);
parameter(const string& name, const word& value); parameter(const string& name, const word& value);
parameter(const string& name, const string& value); parameter(const string& name, const string& value);

View File

@ -537,14 +537,22 @@ const vmime::utility::file::path posixFileSystemFactory::stringToPathImpl(const
while ((offset = str.find_first_of("/", offset)) != vmime::string::npos) while ((offset = str.find_first_of("/", offset)) != vmime::string::npos)
{ {
if (offset != prev) if (offset != prev)
path.appendComponent(vmime::string(str.begin() + prev, str.begin() + offset)); {
path.appendComponent
(vmime::utility::file::path::component
(vmime::string(str.begin() + prev, str.begin() + offset)));
}
prev = offset + 1; prev = offset + 1;
offset++; offset++;
} }
if (prev < str.length()) if (prev < str.length())
path.appendComponent(vmime::string(str.begin() + prev, str.end())); {
path.appendComponent
(vmime::utility::file::path::component
(vmime::string(str.begin() + prev, str.end())));
}
return (path); return (path);
} }

View File

@ -69,14 +69,22 @@ const vmime::utility::file::path windowsFileSystemFactory::stringToPathImpl(cons
while ((offset = str.find_first_of("\\", offset)) != vmime::string::npos) while ((offset = str.find_first_of("\\", offset)) != vmime::string::npos)
{ {
if (offset != prev) if (offset != prev)
path.appendComponent(vmime::string(str.begin() + prev, str.begin() + offset)); {
path.appendComponent
(vmime::utility::file::path::component
(vmime::string(str.begin() + prev, str.begin() + offset)));
}
prev = offset + 1; prev = offset + 1;
offset++; offset++;
} }
if (prev < str.length()) if (prev < str.length())
path.appendComponent(vmime::string(str.begin() + prev, str.end())); {
path.appendComponent
(vmime::utility::file::path::component
(vmime::string(str.begin() + prev, str.end())));
}
return (path); return (path);
} }

View File

@ -44,10 +44,34 @@ class VMIME_EXPORT word : public headerFieldValue
public: public:
/** Construct an empty word.
* Charset is set to the current locale charset.
*/
word(); word();
/** Construct a word by copying another word.
*/
word(const word& w); word(const word& w);
word(const string& buffer); // Defaults to local charset
/** Construct a word using a string buffer.
* Charset is set to the current locale charset.
*/
explicit word(const string& buffer);
/** Construct a word using a string buffer and a specified charset.
*
* @param buffer string buffer
* @param charset charset in which the string is encoded
*/
word(const string& buffer, const charset& charset); word(const string& buffer, const charset& charset);
/** Construct a word using a string buffer and a specified charset
* and language tag (RFC-1766).
*
* @param buffer string buffer
* @param charset charset in which the string is encoded
* @param lang language tag, in the format specified by RFC-1766
*/
word(const string& buffer, const charset& charset, const string& lang); word(const string& buffer, const charset& charset, const string& lang);
/** Return the raw data for this encoded word. /** Return the raw data for this encoded word.