[tor-commits] [goptlib/master] Test that escape doesn't modify strings without NL and '\x00'.

dcf at torproject.org dcf at torproject.org
Wed Oct 8 22:49:53 UTC 2014


commit 1f47c1e30389fbf9e14d29deac1abcb30617d9ec
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Oct 8 14:44:35 2014 -0700

    Test that escape doesn't modify strings without NL and '\x00'.
    
    The problem here is double-escaping of backslashes, because backslash is
    used to escape SMETHOD ARGS, and the escape function is escaping them
    again.
    
    https://trac.torproject.org/projects/tor/ticket/12930#comment:3
---
 pt_test.go |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pt_test.go b/pt_test.go
index f104cb0..456313a 100644
--- a/pt_test.go
+++ b/pt_test.go
@@ -35,8 +35,11 @@ func TestEscape(t *testing.T) {
 
 	check := func(input string) {
 		output := escape(input)
+		if stringIsSafe(input) && input != output {
+			t.Errorf("escape(%q) → %q despite being safe", input, output)
+		}
 		if !stringIsSafe(output) {
-			t.Errorf("escape(%q) → %q", input, output)
+			t.Errorf("escape(%q) → %q is not safe", input, output)
 		}
 	}
 	for _, input := range tests {





More information about the tor-commits mailing list