summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-06-03 12:25:57 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-06-03 12:46:12 (GMT)
commit21fda3308975201eeebeacd98e2b587ef4448862 (patch)
treee8aebe473a636cf5a312814d4054d8af0d9ad6a6 /Swiften/IDN
parent10334c139670861d4860da59ad837fc3fe6fd41e (diff)
downloadswift-21fda3308975201eeebeacd98e2b587ef4448862.zip
swift-21fda3308975201eeebeacd98e2b587ef4448862.tar.bz2
Limit the use of the SafeString type.
Diffstat (limited to 'Swiften/IDN')
-rw-r--r--Swiften/IDN/StringPrep.cpp12
-rw-r--r--Swiften/IDN/StringPrep.h4
2 files changed, 8 insertions, 8 deletions
diff --git a/Swiften/IDN/StringPrep.cpp b/Swiften/IDN/StringPrep.cpp
index f8ebb2c..140e130 100644
--- a/Swiften/IDN/StringPrep.cpp
+++ b/Swiften/IDN/StringPrep.cpp
@@ -28,14 +28,14 @@ using namespace Swift;
}
template<typename StringType, typename ContainerType>
- StringType getStringPrepared(const StringType& s, StringPrep::Profile profile) {
+ ContainerType getStringPrepared(const StringType& s, StringPrep::Profile 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 StringType(&input[0]);
+ return input;
}
else {
- return StringType();
+ return ContainerType();
}
}
}
@@ -43,11 +43,11 @@ using namespace Swift;
namespace Swift {
std::string StringPrep::getPrepared(const std::string& s, Profile profile) {
- return getStringPrepared< std::string, std::vector<char> >(s, profile);
+ return std::string(vecptr(getStringPrepared< std::string, std::vector<char> >(s, profile)));
}
-SafeString StringPrep::getPrepared(const SafeString& s, Profile profile) {
- return getStringPrepared<SafeString, std::vector<char, SafeAllocator<char> > >(s, profile);
+SafeByteArray StringPrep::getPrepared(const SafeByteArray& s, Profile profile) {
+ return createSafeByteArray(reinterpret_cast<const char*>(vecptr(getStringPrepared<SafeByteArray, std::vector<char, SafeAllocator<char> > >(s, profile))));
}
}
diff --git a/Swiften/IDN/StringPrep.h b/Swiften/IDN/StringPrep.h
index fc75118..dc8fadc 100644
--- a/Swiften/IDN/StringPrep.h
+++ b/Swiften/IDN/StringPrep.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <Swiften/Base/SafeString.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class StringPrep {
@@ -20,6 +20,6 @@ namespace Swift {
};
static std::string getPrepared(const std::string& s, Profile profile);
- static SafeString getPrepared(const SafeString& s, Profile profile);
+ static SafeByteArray getPrepared(const SafeByteArray& s, Profile profile);
};
}