From 52e5d74becd6ec100718be177bb60d12d80a774d Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 17 Feb 2015 22:12:20 +0100 Subject: [PATCH] Made word/parameter constructor with 'string' explicit to avoid implicit use of default charset. --- examples/example6.cpp | 2 +- src/vmime/parameter.hpp | 2 +- src/vmime/platforms/posix/posixFile.cpp | 12 ++++++++-- src/vmime/platforms/windows/windowsFile.cpp | 12 ++++++++-- src/vmime/word.hpp | 26 ++++++++++++++++++++- 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/examples/example6.cpp b/examples/example6.cpp index 5d8c7e64..27c6e157 100644 --- a/examples/example6.cpp +++ b/examples/example6.cpp @@ -639,7 +639,7 @@ static void connectStore() : std::string(path.begin() + s, path.begin() + p); if (!x.empty()) - newFolder = newFolder->getFolder(x); + newFolder = newFolder->getFolder(vmime::utility::path::component(x)); if (p == std::string::npos) break; diff --git a/src/vmime/parameter.hpp b/src/vmime/parameter.hpp index 682c391b..a97408b9 100644 --- a/src/vmime/parameter.hpp +++ b/src/vmime/parameter.hpp @@ -44,7 +44,7 @@ private: public: - parameter(const string& name); + explicit parameter(const string& name); parameter(const string& name, const word& value); parameter(const string& name, const string& value); diff --git a/src/vmime/platforms/posix/posixFile.cpp b/src/vmime/platforms/posix/posixFile.cpp index 9387414d..9093b52e 100644 --- a/src/vmime/platforms/posix/posixFile.cpp +++ b/src/vmime/platforms/posix/posixFile.cpp @@ -537,14 +537,22 @@ const vmime::utility::file::path posixFileSystemFactory::stringToPathImpl(const while ((offset = str.find_first_of("/", offset)) != vmime::string::npos) { 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; offset++; } 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); } diff --git a/src/vmime/platforms/windows/windowsFile.cpp b/src/vmime/platforms/windows/windowsFile.cpp index 5ecafa58..b743641b 100644 --- a/src/vmime/platforms/windows/windowsFile.cpp +++ b/src/vmime/platforms/windows/windowsFile.cpp @@ -69,14 +69,22 @@ const vmime::utility::file::path windowsFileSystemFactory::stringToPathImpl(cons while ((offset = str.find_first_of("\\", offset)) != vmime::string::npos) { 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; offset++; } 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); } diff --git a/src/vmime/word.hpp b/src/vmime/word.hpp index 2c6ecb57..e7d12715 100644 --- a/src/vmime/word.hpp +++ b/src/vmime/word.hpp @@ -44,10 +44,34 @@ class VMIME_EXPORT word : public headerFieldValue public: + /** Construct an empty word. + * Charset is set to the current locale charset. + */ word(); + + /** Construct a word by copying another word. + */ 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); + + /** 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); /** Return the raw data for this encoded word.