aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2013-06-12 16:36:13 +0300
committerNick Mathewson <nickm@torproject.org>2013-07-18 08:45:03 -0400
commit1a0cf08841904940ed46b2fcfd79cf65c65a1a6c (patch)
tree67cc87d4e1d641829243ee81908cef0a5bec4353
parentea72958f25f6326d6947c8cd4ef185912582d436 (diff)
downloadtor-1a0cf08841904940ed46b2fcfd79cf65c65a1a6c.tar
tor-1a0cf08841904940ed46b2fcfd79cf65c65a1a6c.tar.gz
Rename tor_escape_str_for_socks_arg() to something more generic.
Since we are going to be using that function to also escape parameters passed to transport proxies using environment variables.
-rw-r--r--src/common/util.c2
-rw-r--r--src/common/util.h4
-rw-r--r--src/or/transports.c2
-rw-r--r--src/test/test_util.c14
4 files changed, 11 insertions, 11 deletions
diff --git a/src/common/util.c b/src/common/util.c
index bd38a6280..eb932f305 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1227,7 +1227,7 @@ escaped(const char *s)
* <b>chars_to_escape</b>. The returned string is allocated on the
* heap and it's the responsibility of the caller to free it. */
char *
-tor_escape_str_for_socks_arg(const char *string, const char *chars_to_escape)
+tor_escape_str_for_pt_args(const char *string, const char *chars_to_escape)
{
char *new_string = NULL;
char *new_cp = NULL;
diff --git a/src/common/util.h b/src/common/util.h
index ba0ec9868..0a8e4a23f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -231,8 +231,8 @@ int tor_digest256_is_zero(const char *digest);
char *esc_for_log(const char *string) ATTR_MALLOC;
const char *escaped(const char *string);
-char *tor_escape_str_for_socks_arg(const char *string,
- const char *chars_to_escape);
+char *tor_escape_str_for_pt_args(const char *string,
+ const char *chars_to_escape);
struct smartlist_t;
int tor_vsscanf(const char *buf, const char *pattern, va_list ap) \
diff --git a/src/or/transports.c b/src/or/transports.c
index 6f1770238..6b6882ae7 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -1440,7 +1440,7 @@ pt_stringify_socks_args(const smartlist_t *socks_args)
SMARTLIST_FOREACH_BEGIN(socks_args, const char *, s) {
/* Escape ';' and '\'. */
- escaped_string = tor_escape_str_for_socks_arg(s, ";\\");
+ escaped_string = tor_escape_str_for_pt_args(s, ";\\");
if (!escaped_string)
goto done;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 54a089b36..f7513c0f3 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -796,37 +796,37 @@ test_util_expand_filename(void)
}
#endif
-/** Test tor_escape_str_for_socks_arg(). */
+/** Test tor_escape_str_for_pt_args(). */
static void
test_util_escape_string_socks(void)
{
char *escaped_string = NULL;
/** Simple backslash escape. */
- escaped_string = tor_escape_str_for_socks_arg("This is a backslash: \\", ";\\");
+ escaped_string = tor_escape_str_for_pt_args("This is a backslash: \\",";\\");
test_assert(escaped_string);
test_streq(escaped_string, "This is a backslash: \\\\");
tor_free(escaped_string);
/** Simple semicolon escape. */
- escaped_string = tor_escape_str_for_socks_arg("First rule: Do not use ;", ";\\");
+ escaped_string = tor_escape_str_for_pt_args("First rule:Do not use ;",";\\");
test_assert(escaped_string);
- test_streq(escaped_string, "First rule: Do not use \\;");
+ test_streq(escaped_string, "First rule:Do not use \\;");
tor_free(escaped_string);
/** Empty string. */
- escaped_string = tor_escape_str_for_socks_arg("", ";\\");
+ escaped_string = tor_escape_str_for_pt_args("", ";\\");
test_assert(escaped_string);
test_streq(escaped_string, "");
tor_free(escaped_string);
/** Escape all characters. */
- escaped_string = tor_escape_str_for_socks_arg(";\\;\\", ";\\");
+ escaped_string = tor_escape_str_for_pt_args(";\\;\\", ";\\");
test_assert(escaped_string);
test_streq(escaped_string, "\\;\\\\\\;\\\\");
tor_free(escaped_string);
- escaped_string = tor_escape_str_for_socks_arg(";", ";\\");
+ escaped_string = tor_escape_str_for_pt_args(";", ";\\");
test_assert(escaped_string);
test_streq(escaped_string, "\\;");
tor_free(escaped_string);