return result;
}
-String Utility::Join(const Array::Ptr& tokens, char separator)
+String Utility::Join(const Array::Ptr& tokens, char separator, bool escapeSeparator)
{
String result;
bool first = true;
ObjectLock olock(tokens);
BOOST_FOREACH(const Value& vtoken, tokens) {
String token = Convert::ToString(vtoken);
- boost::algorithm::replace_all(token, "\\", "\\\\");
-
- char sep_before[2], sep_after[3];
- sep_before[0] = separator;
- sep_before[1] = '\0';
- sep_after[0] = '\\';
- sep_after[1] = separator;
- sep_after[2] = '\0';
- boost::algorithm::replace_all(token, sep_before, sep_after);
+
+ if (escapeSeparator) {
+ boost::algorithm::replace_all(token, "\\", "\\\\");
+
+ char sep_before[2], sep_after[3];
+ sep_before[0] = separator;
+ sep_before[1] = '\0';
+ sep_after[0] = '\\';
+ sep_after[1] = separator;
+ sep_after[2] = '\0';
+ boost::algorithm::replace_all(token, sep_before, sep_after);
+ }
if (first)
first = false;
static void QueueAsyncCallback(const boost::function<void (void)>& callback, SchedulerPolicy policy = DefaultScheduler);
static String NaturalJoin(const std::vector<String>& tokens);
- static String Join(const Array::Ptr& tokens, char separator);
+ static String Join(const Array::Ptr& tokens, char separator, bool escapeSeparator = true);
static String FormatDuration(double duration);
static String FormatDateTime(const char *format, double ts);
{
// Iterate over the key name and escape commas and spaces with a backslash
String result = str;
+ boost::algorithm::replace_all(result, "\"", "\\\"");
+ boost::algorithm::replace_all(result, "=", "\\=");
boost::algorithm::replace_all(result, ",", "\\,");
boost::algorithm::replace_all(result, " ", "\\ ");
// Ensure you hold a lock against m_DataBuffer so that things
// don't go missing after creating the body and clearing the buffer
- String body = Utility::Join(m_DataBuffer, '\n');
+ String body = Utility::Join(m_DataBuffer, '\n', false);
m_DataBuffer->Clear();
HttpRequest req(stream);