summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/IDN/LibIDNConverter.cpp')
-rw-r--r--Swiften/IDN/LibIDNConverter.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Swiften/IDN/LibIDNConverter.cpp b/Swiften/IDN/LibIDNConverter.cpp
index c4a1c18..45b1d14 100644
--- a/Swiften/IDN/LibIDNConverter.cpp
+++ b/Swiften/IDN/LibIDNConverter.cpp
@@ -33,48 +33,48 @@ namespace {
assert(false);
return 0;
}
template<typename StringType, typename ContainerType>
ContainerType getStringPreparedInternal(const StringType& s, IDNConverter::StringPrepProfile profile) {
ContainerType input(s.begin(), s.end());
input.resize(MAX_STRINGPREP_SIZE);
if (stringprep(&input[0], MAX_STRINGPREP_SIZE, static_cast<Stringprep_profile_flags>(0), getLibIDNProfile(profile)) == 0) {
return input;
}
else {
return ContainerType();
}
}
}
namespace Swift {
std::string LibIDNConverter::getStringPrepared(const std::string& s, StringPrepProfile profile) {
std::vector<char> preparedData = getStringPreparedInternal< std::string, std::vector<char> >(s, profile);
if (preparedData.empty()) {
throw std::exception();
}
return std::string(vecptr(preparedData));
}
SafeByteArray LibIDNConverter::getStringPrepared(const SafeByteArray& s, StringPrepProfile profile) {
std::vector<char, SafeAllocator<char> > preparedData = getStringPreparedInternal<SafeByteArray, std::vector<char, SafeAllocator<char> > >(s, profile);
if (preparedData.empty()) {
throw std::exception();
}
return createSafeByteArray(reinterpret_cast<const char*>(vecptr(preparedData)));
}
-std::string LibIDNConverter::getIDNAEncoded(const std::string& domain) {
+boost::optional<std::string> LibIDNConverter::getIDNAEncoded(const std::string& domain) {
char* output;
- if (idna_to_ascii_8z(domain.c_str(), &output, 0) == IDNA_SUCCESS) {
+ if (idna_to_ascii_8z(domain.c_str(), &output, IDNA_USE_STD3_ASCII_RULES) == IDNA_SUCCESS) {
std::string result(output);
free(output);
return result;
}
else {
- return domain;
+ return boost::optional<std::string>();
}
}
}